How to use Dynamic 'Filter Conditions' in a Business rule?

Suggy
Giga Sage

Today we are using a Filter condition like this:

Suggy_0-1751287108256.png

The groups can change often, which needs an update to the Business rule, and I want to avoid that.

 

Is there way to use a script or system property or anything in the 'Filter conditions' or under the 'Condition' field under advanced section and make it dynamic?

 

PS - I know that can achieve it by writing code in script field, I dont want run the script. I want to run the script only when the condition matches. ie if assignment group is one of (A or B or C) etc

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Suggy 

you can check the property value in Advanced condition field of business rule

Filter conditions are for more simpler conditions and advanced condition can handle scripting.

your advanced condition will look like this

system property will hold comma separated sysIds of the 3 groups

gs.getProperty('propertyName').split(',').indexOf(current.assignment_group.sys_id.toString()) > -1

AnkurBawiskar_0-1751289412823.png

 

You can also try to use Dynamic filter options, I haven't tested this

Create a dynamic filter option 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Mark Manders
Mega Patron

You can by using the 'condition' field on the 'advanced' tab and write a script include to get the groups from a system property.

But I don't really see any upside to that, because your BR would trigger the lookup to the script include and property and then just doesn't trigger the BR, while you can make it way easier by just applying that in your BR script. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi @Mark Manders 

The Condition field decides if the Business rule should run or not right. Incase the criteria is not met, the Business rule will not run at all.

If we write the same logic inside the script part, the BR runs, and if the criteria is not met, it stops executing.

 

If everything (condition logic) is handled with the script field, then why 'Filter Conditions' and 'Condition' field.

 

Please correct me if my understanding is wrong 🙂

 

statement to specify when the business rule should run. 

My question was more about the reason behind you don't want to run it. If it triggers and doesn't do a thing because of the script in it, it has the same result as executing a script include to run to decide if the BR needs to run or not. 
Ankur's solution will also work, but the BR will be calling the system property to check on the assignment group. 
No matter what you do, you will be performing some lookup and script execution to prevent the BR to trigger. My assumption was that you don't want the BR to trigger to not use any instance resources. You will do so, because you need to get the information from somewhere.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Thanks for the clarification, Mark:)