Skip to main content
Participant
August 25, 2022
Answered

Round to nearest 5

  • August 25, 2022
  • 3 replies
  • 738 views

I am trying to take an input value and round it up to the nearest whole 5 and then use that new value in an IF formula.  However there is some detail I am getting incorrect as when the rounded value is outside of the parameters it returns the result anyway.  Please where did I go wrong.

 

var SST = Number(this.getField("SST").value);
var SLT = Number(this.getField("SLT").value);
var SCT = Number(this.getField("SCT").value);
var Ref = this.getField("Ref").valueAsString;

var RSST = Number(Math.round((SST/5)*5).value);

 

if(Ref != "R410A") event.value = "";

else if (RSST = 50 && SCT == 120 && SLT == 50 ) event.value = 150-SCT;

else event.value = "";

 

Thank you.

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

You have few errors, in your script.

Change: RSST = 50 to: RSST == 50

Change variable RSST to this:

var RSST = Math.round(SST/5)*5;

3 replies

try67
Community Expert
Community Expert
August 25, 2022

You have an error in your code.

Change:

if (RSST = 50

To:

if (RSST == 50

 

Participant
August 25, 2022

Nesa,

I tried every iteration I could think of to get this to work and I swear I had to have tried that.  You must be one of the people that nothing works until you show up and just by being there everything works.

 

Thank you again.

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 25, 2022

You have few errors, in your script.

Change: RSST = 50 to: RSST == 50

Change variable RSST to this:

var RSST = Math.round(SST/5)*5;