Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to write multiple conditions and set values in Fix Script?

Kamesh Sangadi
Tera Contributor

I need to write a fix script where I need to set values based on multiple conditions.

if(actual value = 0, then new value = neutrals)

if(actual value = 1, then new value = passive)

if(actual value = 2, then new value = neutrals)

if(actual value = 3, then new value = passive)

Can you please help me on this. Thanks in advance.

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, I would recommend that you use a JavaScript switch statement.

https://www.w3schools.com/js/js_switch.asp

 

Sagar Pagar
Tera Patron

Better to go with switch to write multiple conditions.

 

Or try with multiple if-else blocks.

if(){
}

else if(condition1){

// add code

} else if(condition2){

// add code

}else{

// add code

}

 

Thanks,

Sagar Pagar

The world works with ServiceNow