Check for more values in the if condition
						
					
					
				
			
		
	
			
	
	
	
	
	
Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
02-21-2022 08:21 AM
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
	
		
		
			
			
			
					
	
			Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
02-21-2022 08:34 AM
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
}
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
02-21-2022 08:46 AM
Use Switch Case method. refer to below URL.
https://www.w3schools.com/js/js_switch.asp
