Clarification on Filter Conditions vs Condition in Business Rule

Astik Thombare
Tera Sage

Hi All,

 

I have a quick question regarding Business Rules. There are two fields: Filter Conditions and Condition.

 

I'm curious to know how these are evaluated:

 

Does the system first evaluate the Filter Conditions, and if they pass, then evaluate the Condition field?

 

Or are both evaluated at the same time before the Business Rule runs?

 

 

Additionally, I’d like to understand the behavior when using an "AND" condition:

 

If multiple conditions are defined with AND, and the first one fails, will the system still evaluate the remaining conditions?

 

Or will it stop evaluating further since all conditions must be true?

 

 

Looking forward to your insights.

 

Thanks in advance!

 

Thanks in advance!

1 ACCEPTED SOLUTION

Cassandra Kittl
Tera Guru

I'm going to approach this from data going through a pipe:

  • Does the system first evaluate the Filter Conditions, and if they pass, then evaluate the Condition field? 

Filter Conditions are like a gate - the data must be able to go through the gate to continue down the pipe.

When addressing the 'lake' of Incidents, these conditions apply to those that meet my filter of Active incidents.

 

  • Additionally, I’d like to understand the behavior when using an "AND" condition:
  • If multiple conditions are defined with AND, and the first one fails, will the system still evaluate the remaining conditions?

Again with the 'gate' - the combo of conditions are like a lock. All must pass. I don't think it matters in the order of addressing as if one is not met, it fails.

There is a caveat though when it comes to using NQL and the 'contains' parameter it that it treats the search as an inherit 'or' - which can throw off your results.

 

Please mark this answer as "Helpful" if it helped. 

 

 

View solution in original post

3 REPLIES 3

Cheikh Ahmadou
Tera Guru

 

1. Filter Conditions vs Condition (Script Field)

- Filter Conditions

  • These are the conditions you define in the “When to run” section using the graphical filter builder (e.g., Active is true AND Priority is High).

  • These are evaluated first.

  • If they do not match, the Business Rule does not run at all, and the script in the Condition field is never evaluated.

 

- Condition (Script Field)

  • This is the JavaScript Condition field in the Business Rule.

  • If the Filter Conditions are met, then the script condition is evaluated.

  • The Business Rule runs only if both are true.

    Conclusion:
    Yes the system first evaluates the Filter Conditions, and only if they pass, it evaluates the Condition script.

 

2. Evaluation of multiple conditions with AND

In both the Filter Conditions and within a Condition script, logical AND behaves as you’d expect in most programming:

In Filter Conditions:

  • Conditions combined with AND are evaluated left to right.

  • If the first condition fails, it may short-circuit and skip evaluating the rest 

 

Cassandra Kittl
Tera Guru

I'm going to approach this from data going through a pipe:

  • Does the system first evaluate the Filter Conditions, and if they pass, then evaluate the Condition field? 

Filter Conditions are like a gate - the data must be able to go through the gate to continue down the pipe.

When addressing the 'lake' of Incidents, these conditions apply to those that meet my filter of Active incidents.

 

  • Additionally, I’d like to understand the behavior when using an "AND" condition:
  • If multiple conditions are defined with AND, and the first one fails, will the system still evaluate the remaining conditions?

Again with the 'gate' - the combo of conditions are like a lock. All must pass. I don't think it matters in the order of addressing as if one is not met, it fails.

There is a caveat though when it comes to using NQL and the 'contains' parameter it that it treats the search as an inherit 'or' - which can throw off your results.

 

Please mark this answer as "Helpful" if it helped. 

 

 

I tried testing this in my instance and saw something unexpected.
I created a Business Rule with a Filter Condition of State = In Progress. In the Condition (script) field, I added a Script Include call that simply does a gs.addErrorMessage("Condition field executed") and returns true/false.
Then I tested it on an Incident where the state was On Hold (so the filter shouldn’t match).
The Filter should block everything, meaning the Condition script should not be evaluated. But in my case the error message still appeared, which shows that the Condition script was executed even though the Filter condition failed. The main Business Rule script did not run, but the Condition code definitely fired.
This seems to contradict the model that the Filter completely prevents the Condition field from being evaluated.
Do you have any idea why the Condition script still executes in this scenario, or have you seen this behavior before?