Skip to main content
pamc90562799
Participating Frequently
June 1, 2017
Answered

Display percent field

  • June 1, 2017
  • 1 reply
  • 515 views

I am trying to create a percent field base off of 2 other fields.  I have 2 number fields: ChangeAmt and OrigAmt and would like to display a percent field that cant be changed.  Below is what I currently have and it displays 0.00%

event.value = (ChangeAmt/OrigAmt);

This topic has been closed for replies.
Correct answer try67

That's not a correct syntax for a custom calculation script. Use this instead:

var v1 = Number(this.getField("ChangeAmt").value);

var v2 = Number(this.getField("OrigAmt").value);

if (v2==0) event.value = "";

else event.value = (v1/v2);

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 1, 2017

That's not a correct syntax for a custom calculation script. Use this instead:

var v1 = Number(this.getField("ChangeAmt").value);

var v2 = Number(this.getField("OrigAmt").value);

if (v2==0) event.value = "";

else event.value = (v1/v2);

pamc90562799
Participating Frequently
June 1, 2017

I still get a zero value.  Is there a trick to making it launch this script?  Here is what I entered.

Also, as you can tell - I'm a beginner at java scripting.  Can you point me in a good place to learn more?

try67
Community Expert
Community Expert
June 1, 2017

JS is case-sensitive, and you did not copy the code I provided correctly, which is why it's not working.