Skip to main content
Participant
October 9, 2017
Answered

Creating if/then condition for complex calculation

  • October 9, 2017
  • 1 reply
  • 358 views

I have made a calculation for a field:

this.getField("Rental Year 3").value = (this.getField("Rental Year 2").value * (this.getField("Annual Increase").value /100)) + this.getField("Rental Year 2").value;

However, I only want the calculation to apply if another field (Lease Term) has a value greater than or equal to 3. If the value is less than three I would like this field to equal 0.

How do I add this condition?

This topic has been closed for replies.
Correct answer Bernd Alheit

Use something like this:

var val = 0;

if (this.getField("Lease Term").value >= 3)

  val = (this.getField("Rental Year 2").value * (this.getField("Annual Increase").value /100)) + this.getField("Rental Year 2").value;

this.getField("Rental Year 3").value = val;

1 reply

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
October 9, 2017

Use something like this:

var val = 0;

if (this.getField("Lease Term").value >= 3)

  val = (this.getField("Rental Year 2").value * (this.getField("Annual Increase").value /100)) + this.getField("Rental Year 2").value;

this.getField("Rental Year 3").value = val;