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

Round to nearest 5

New Here ,
Aug 25, 2022 Aug 25, 2022

Copy link to clipboard

Copied

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

Views

324

Translate

Translate

Report

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

correct answers 1 Correct answer

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;

Votes

Translate

Translate
Community Expert ,
Aug 25, 2022 Aug 25, 2022

Copy link to clipboard

Copied

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;

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

You have an error in your code.

Change:

if (RSST = 50

To:

if (RSST == 50

 

Votes

Translate

Translate

Report

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