Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Check for more values in the if condition

Harish74
Tera Expert

Hi,

I'm trying to write an "if" block to check for some values. I have got more values to verify in the if statement of a Business rule. The script is working fine. But I'm trying to find easy and best practice to achieve this. 

if(current.u_level_3.name=='IT Service Systems'||current.u_level_3.name=='Marketing'||current.u_level_3.name=='Sales'){
		//
	}

Please help me the easiest way to achieve this.

2 REPLIES 2

Mark117
Tera Expert

Easiest option would be to use an array of values then check the result using indexOf, so something along the lines of:

var valuesArray = [
    'IT Service Systems',
    'Marketing',
    'Sales'
// insert other values into the array as needed
];

var l3val = current.u_level_3.getValue('name');

if (valueArray.indexOf(l3val) === -1) {
    // Value is not in the list
} else {
    // Value is in the list
}

User177031
Kilo Guru

Use Switch Case method. refer to below URL.

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