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

Business Rule Condition Script Evaluated Even When Filter Conditions Are Not Met?

gurralanavi
Tera Contributor

Hi All,

I have a Business Rule on sc_task with filter conditions for only two specific catalog items.

I noticed that an update on a task belonging to a different catalog item was still triggering the Condition script. To test, I added:

gs.log('Condition evaluated for ' + current.number);

and I can see the log being generated even when the record does not meet the filter conditions.

My understanding was that the execution order is:

Filter Conditions
→ Condition
→ Script

So I'm wondering:

Why is the Condition script being evaluated when the record does not satisfy the filter conditions? Is this expected behavior in ServiceNow?

Thanks in advance for any insights.

2 ACCEPTED SOLUTIONS

annb19
Tera Guru

Hi @gurralanavi ,
According to the document below, Filter Conditions and Advanced Condition scripts in ServiceNow are evaluated simultaneously, so seeing your log fire even when the record doesn’t match the filter is expected behavior.
Classic Business rules • Australia Build workflows • Docs | ServiceNow

View solution in original post

3 REPLIES 3

annb19
Tera Guru

Hi @gurralanavi ,
According to the document below, Filter Conditions and Advanced Condition scripts in ServiceNow are evaluated simultaneously, so seeing your log fire even when the record doesn’t match the filter is expected behavior.
Classic Business rules • Australia Build workflows • Docs | ServiceNow

Juhi Poddar
Kilo Patron

Hi @gurralanavi,

 

This is expected platform behavior. ServiceNow evaluates both the UI Filter Conditions and the advanced Condition Script simultaneously as a combined boolean check before deciding whether to execute the Business Rule.

 

To prevent your condition script from evaluating unnecessarily, the cleanest fix is to clear the Condition Script field entirely and handle the check inside your main script body instead:

(function executeRule(current, previous) {
    
    // Perform your check inside the script body
    if (!current.request_item.nil() && current.request_item.cat_item == 'TARGET_SYS_ID') {
        // Your logic here
    }

})(current, previous);

This ensures your logic only runs when all criteria are met.

 

Hope this helps!

 

Thank you!

Juhi Poddar

Thank You!
Juhi Poddar