I'm trying to do a conditional formula where it compares two fields, and only calculates if one field is greater than the other. Here is the code I've cobbled together from multiple other codes that did what I wanted -in part-.
Can you guys tell me where I'm going wrong?
var 12 = this.getField("Line 12").value;
var 13 = this.getField("Line 13g").value;
if( 12 > 13) event.value = this.getField("Line 12").value - this.getField("Line 13g").value;
else event.value = "0"
Don't use numbers as name of variables.
New error, now.
Variable name can't start with a number.
Thanks to you, too!
New error. Any help appreciated!
In your screenshot, notice the message "illegal character 2: at line 3".
Look at the quotes used in the line of code for "var B".
Make sure you're using the same quote typeface as you have in the rest of your script.
Also, to be on the safe side, you may want to close the last line for event.value = "0" with a semicolon ";".
Thank you! That's 100% what I did. Now I'm getting this:
Why have you removed " after 13g?
Accident because I retyped the whole this to make sure the font matched and forgot the "
Now your missing a quote in this line "Line 13g
Since you declared variables already your script can be typed in much shorter like:
if (A > B) event.value = A-B;
PERFECT! Changed that line and it's working now.
THANKS EVERYBODY! Combination of correct answers to help me limp along! Got it worked out!