Skip to main content
Participating Frequently
September 15, 2024
Answered

If a Field is grater than or less than

  • September 15, 2024
  • 1 reply
  • 908 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 

Nesa Nurani
Community Expert
Community Expert
September 16, 2024

I see what you mean,  I made it. Confusing...


The "numofmonths" counts the number of months. 

if the "numofmonths" is less than 2 then the "result " field = 0

if the "nunofmonths" equals 2 then the "result"  field = 5%

if the "numofmonths" is greater than 2 the "result" field = 10%

 

I hope that makes sense.. can you help me figure it out?


If this explanation is the last one, try using the script I posted, it should do what you're asking for.