Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Round to nearest 5

New Here ,
Aug 25, 2022 Aug 25, 2022

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.

TOPICS
JavaScript
698
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Aug 25, 2022 Aug 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;

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2022 Aug 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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 25, 2022 Aug 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2022 Aug 25, 2022
LATEST

You have an error in your code.

Change:

if (RSST = 50

To:

if (RSST == 50

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines