Copy link to clipboard
Copied
Trying to convert following formcalc script to javascript, and not getting to work. Just wondering if someone could take a look at and possibly convert to javascript? Thank you so much! IF(Personnel_nab>=0,Personnel_nab+-Personnel_osb)
OK, thank you! Very helpful!
Copy link to clipboard
Copied
Please show us your attempt, so we can help you understand what is wrong rather than just solving the one problem.
Copy link to clipboard
Copied
Sorry, it is incomplete.
if (Personnel_nab >= 0) {
Personnel_nab = Personnel_nab+-Personnel_osb;
}
Copy link to clipboard
Copied
Ok, the key thing you are missing is connecting it to the fields. In JavaScript a name is just a place to keep stuff, not the name of a field unless you do something like this:
var Personnel_nab = this.getField("Personnel_nab") ;
and so on for each field. Then your lines should be OK. Pay very close attention to exact details like the quotes used, punctuation, and capital letters like the F in getField.
Also get in the habit of opening the JavaScript console. If anything goes wrong, your messages will show up only in the console.
Copy link to clipboard
Copied
OK, thank you! Very helpful!