Skip to main content
Participant
August 2, 2022
Answered

Custom Calculation Formula Not Updating Correctly

  • August 2, 2022
  • 1 reply
  • 716 views

Hi. I am trying to add a custom calculation formula and I don't have much experience with these. I would like my form to automatically update one text field depending on what is added to another text field. For example, if 951000 through 954000 is added to DeptID I want Fund to autofill as 225 and if 956900 is added to DeptID I want Fund to autocalculate as 569.  If 957000 is entered in DeptID I want Fund to autofill as 570. I am using the custom calculation below and it works the first time I enter the DeptID but it doesn't update if I change the DeptID. And if I leave the DeptID blank it is keeping 569 in Fund.  What am I doing wrong? I am entering this code in the Fund custom calculation:

var DeptID=Number(this.getField("DeptID").valueAsString);

if(DeptID=956900) event.value=569; else if (DeptID=957000)event.value=570;else event.value="225";

This topic has been closed for replies.
Correct answer try67

Change:

if(DeptID=956900)

To:

if(DeptID==956900)

And:

else if (DeptID=957000)

to:

else if (DeptID==957000)

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 2, 2022

Change:

if(DeptID=956900)

To:

if(DeptID==956900)

And:

else if (DeptID=957000)

to:

else if (DeptID==957000)

Participant
August 2, 2022

That worked - thank you so much!!