The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Business Rule

yoli1
Tera Contributor

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'){
		//
	}
11 REPLIES 11

Thank you @Aylee Andersen  for the response, in the filter conditions i just put name of the field ''changes'' and then in the script area i put the code in my "Filter conditions" correct?

I was suggesting you build out the "Filter conditions" like:

Level 3 | changes | AND 

Level 3.Name | is | "IT Service Systems" OR

Level 3.Name | is | "Marketing" OR

Level 3.Name | is | "Sales"

 

But honestly just give it a shot and see if it works as you expect! It's hard for me to know for sure without knowing the exact use case or functionality you're hoping to react to. But if you plug that in you should be able to tell pretty quick if it's doing what you want 😊 

@Aylee Andersen Honestly the use case is pretty simple just if the value of the filed was one of those three names a check box variable will get the value true. building the Filter conditions or using it all in a script both do the job but i was looking for what we can consider best practice

Ahh, I see. If it's that simple, you wouldn't even have to use a script at all! You could do it all with the "Filter conditions" field and "Set field values" field (in the "Action" tab). It'll be easier to maintain and have fewer points of potential failure. Plus, like I mentioned before, it follows the no-code/low-code standard that ServiceNow aims to achieve.

 

Hopefully that makes sense! Sounds like you know what you're doing, so I'll leave it in your hands to decide what you feel is best!

You are Right! Thank you so much @Aylee Andersen 🙂 i just have one quick question about the "Filter conditions" is it necessary to use the ''changes'' one, should it be 

Level 3 | changes | AND 

Level 3.Name | is | "IT Service Systems" OR

Level 3.Name | is | "Marketing" OR

Level 3.Name | is | "Sales" 

Or Just : 

Level 3.Name | is | "IT Service Systems" OR

Level 3.Name | is | "Marketing" OR

Level 3.Name | is | "Sales"

 

Thanks