When using the operator ^NQ in an encoded query within a business rule, the results appear in the list view, but the reference links are not correct.
A filter on a business rule that has a query with the operator ^NQ (second level condition) is applied only on the first part of the query. Although the business rule works correctly in the list, if a filter like Active=true is added, the filter is applied only on the first part of the query (before the ^NQ).

Steps to Reproduce

  1. Create a business rule:
    • Name: Test condition
    • Table: Incident [incident]
    • When: Select before from the drop-down list
    • Query: [Select the check box]
    • Advanced: [Select the check box]
    • Condition: gs.getSession().isInteractive()
    • Script:
      function onBefore(current, previous) {
  2. Load the Incident list view.
    Note the inconsistencies. If you click an incident number, the form for a different incident opens.



This is expected behavior. To understand why this issue occurs, the following details about how the NQ operator works and why it is not appropriate for a business rule are provided.

The NQ (top level OR) operator will OR all previous query terms with following query terms. When there are no previous query terms, it is equivalent to regular OR. 

For example, if the query expression is:

the query is:
      (active = true OR active = false)

However, if there is a query expression already, for example (number=INC000004), then appending the query expression active=true^NQactive=false makes it:


this is equivalent to the query:
    (number=INC000004 AND active = true) OR (active = false)

it is not the expected query:
    (number=INC000004) AND (active = true OR active = false)

When the query is evaluated, if the record INC000004 has active=false, the OR part takes place so the record returned is the first record with active=false. Because the database orders records in an arbitrary manner, this can be any record with active=false and, specifically, it need not be INC000004. 

This is why using NQ operators in a context where it is appended to an existing query yields unexpected results. This includes business rules, etc. When it is used in contexts where the entire query expression is known, the equivalent query is clear. When NQ is appended to an existing query, the equivalent query expression may alter the meaning of the original query itself.

Specifically for a before query business rule, the intent of adding additional query terms is that the result is a subset of the original query. Adding NQ changes the meaning of the entire query. Also note that adding a before query business rule changes the query not just in specific use cases (like list view), but in all use cases where a query is performed (form view).

Related Problem: PRB647484

Seen In

Berlin Patch 9 Hot Fix 5
Eureka Patch 11 Hot Fix 2
Fuji Patch 10
Fuji Patch 12 Hot Fix 1
Fuji Patch 3
Geneva Patch 6
Geneva Patch 7
Geneva Patch 8

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-03-19 03:41:34