Skip to main content
TheRealJamesGunter
Participating Frequently
August 24, 2017
Answered

Need Help Writing Code :( Very New At This

  • August 24, 2017
  • 2 replies
  • 416 views

Can someone tell me how to write a calculation script for this.  Im adding my "Dental" field and "Health" to get the "Total",  Then to the right, there are two fields for "6100" and "1150" (just accounting codes). Anyway, If the "Total" is $784.96 or something, how can i make the first $300 go in the "6100" field and the remaining balance go into the "1150 box?   Thanks Guys!

This topic has been closed for replies.
Correct answer try67

Enter this code as the custom calculation script for "6100":

var cutoff = 784.96;

var total = Number(this.getField("Total").value);

if (total>cutoff) {

    event.value = cutoff;

    this.getField("1150").value = total-cutoff;

} else {
    event.value = total;

    this.getField("1150").value = 0;
}

2 replies

TheRealJamesGunter
Participating Frequently
August 24, 2017

Worked!!! Thanks!!!!  

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 24, 2017

Enter this code as the custom calculation script for "6100":

var cutoff = 784.96;

var total = Number(this.getField("Total").value);

if (total>cutoff) {

    event.value = cutoff;

    this.getField("1150").value = total-cutoff;

} else {
    event.value = total;

    this.getField("1150").value = 0;
}