Copy link to clipboard
Copied
I have created a form that needs an IF Else JavaScript. The form has a field that we enter either a Y (for yes) or N (for no). Another field, Field B, looks at whether there is a Y or N in FieldA and needs to either perform a calculation (product of FieldC * FieldD) if FieldA is a Y and return the result , or return a value of 0 if FieldA is an N. Did I mention I have zero JavaScript skills? So far I have this, but I keep getting "SyntaxError: missing ) in parenthetical 3: at line 4:
var nSubTotal = this.getField("PP").valueAsString;
if(nSubTotal === 'Y') {
event.value = ( OF INSTALLMENTS * Numb of Txble Parcels );
}
else if (nSubTotal === 'N') {
event.value = 0;
}
Copy link to clipboard
Copied
You can't just write out the field names in order to access their values. You need to use the proper methods and properties for that, like this:
this.getField("Field Name").value
Copy link to clipboard
Copied
Thank you very much for the reply.
Copy link to clipboard
Copied
You can use this as custom calculation script of "Field B", just change field names to your actual filed names:
var a = this.getField("Field A").valueAsString;
var c = Number(this.getField("Field C").valueAsString);
var d = Number(this.getField("Field D").valueAsString);
if(a == "Y")
event.value = c*d;
else if(a == "N")
event.value = 0;
else
event.value = "";
Copy link to clipboard
Copied
Thank you so much!