Skip to main content
Participating Frequently
September 15, 2024
Answered

If a Field is grater than or less than

  • September 15, 2024
  • 1 reply
  • 911 views

I'm still learning and I have messed this up.

 

I have a field labeled "numofmonths".  I am trying to create a javascript that says if "numofmonths" is = 2, the value of the "results" field is 5% but if the "numofmonths" is greater than or equal to 3 the "result" field is 10%

 

Can someone help me?

This topic has been closed for replies.
Correct answer Nesa Nurani

Use this as custom calculation script of 'result' field:

 

 

var n = Number(this.getField("numofmonths").valueAsString);

if(n === 2)
 event.value = n*0.05;
else if(n > 2)
 event.value = n*0.1;
else
 event.value = "";

 

 

1 reply

Nesa Nurani
Community Expert
Community Expert
September 15, 2024

Percentage of what value?

Participating Frequently
September 15, 2024

The value of the  "numofmonnths" field 

PDF Automation Station
Community Expert
Community Expert
September 15, 2024

What it is less than 2?  What if it is greater than 2 and less than 3?