Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

dipak_thakor
ServiceNow Employee
As part of Technical governance, it is important to understand the filter conditions vs advanced conditions, so we can avoid any common mistakes.In a ServiceNow business rule, the Filter Conditions in the When to Run section function as the trigger for the execution of the business rule. Meanwhile, the Advanced Conditions, located in the Condition field of the Advanced tab, serve as an additional JavaScript-based condition that must also be satisfied for the script of the business rule to execute. This ensures that more intricate logic is applied only when both sets of conditions are fulfilled.
When to Run Filter Conditions
  • Purpose: To act as the initial gatekeeper or trigger for the business rule. 
     
  • Format: Uses a user-friendly, no-code interface to define conditions based on field values. 
     
  • Execution: The business rule's script will only be considered for execution if these filter conditions are met. 
     
Advanced Conditions
  • Purpose: To add more complex, script-based criteria that the business rule script must meet in addition to the Filter Conditions. 
     
  • Format: A JavaScript expression that evaluates to true or false. 
     
  • Execution: The business rule script runs only when the Filter Conditions are met and this advanced condition also evaluates to true. 
     
Key Differences
  • Complexity: 
    Filter Conditions are for simple, declarative criteria, while Advanced Conditions allow for intricate, dynamic JavaScript logic. 
     
  • Order: 
    The Filter Conditions in the When to Run section are evaluated first. If they are met, then the Advanced Condition is evaluated. 
     
  • Requirement: 
    You must satisfy both the Filter Conditions and the Advanced Condition for the business rule's script to execute. 
6 Comments
Arjun Ayyappan
ServiceNow Employee

@dipak_thakor We see from our tests that both filter conditions and advanced conditions are evaluated together, unlike what you have mentioned. Do you have any production documentation supporting the order of evaluation?

Tamara11
Mega Sage

I have a business rule that has conditions set on the when to run tab and a simple current.variable...changes() condition and it's been trying to run on catalog items other than the one that's listed in the when to run conditions.

 

Tamara11_0-1778193929065.png

Tamara11_1-1778193960488.png

 

Do you have any idea why it would try to run on catalog items other than the one in the when to run conditions?

 

andymcdonald
Mega Guru

I have run into a situation and my observation supports Arjun's assertion above.  The System appears to concatenate the basic and advanced conditions together and evaluate the entire thing, and in fact, the Advanced conditions seem to be evaluated FIRST.  I think it makes much more sense to save the Advanced condition to be evaluated ONLY when the basic conditions pass. 

 

If you know of any SN documentation that actually states this, please let us know! 🙂

Tamara11
Mega Sage

I would sure like to see some documentation also as mine is behaving differently.  Almost like adding an advanced condition overrides the when to run conditions.  Makes me wonder if there' s a system property or something that I'm missing.

andymcdonald
Mega Guru

@TamaraJ 
I have a support case open right now.  The analyst has seen the issue and has asked me to reproduce the issue with a simple test case, which I have done.  Pretty sure this is unexpected for them...I will update you when the case is resolved.
@Rylie Mo we would appreciate a status from your end here.  Thank you.
CS9584455

andymcdonald
Mega Guru

I have received confirmation from ServiceNow that the basic and advanced conditions are actually evaluated together, as we suspected.  In other words, there is no gating causing the advanced conditions to be evaluated only after the basic conditions pass.  Here's a docs reference:

 

https://www.servicenow.com/docs/r/yokohama/application-development/business-rules-classic/c_Business...