- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2019 02:46 AM
Hi All,
I have a requirement to write Query Business rules for ITIL users based on support teams. I need to display records based on following condition.
- Filter A is the list of records based on their support group.
- Filter B is in a case if incidents are raised for the user (requested for / requested by).
Both are connected with OR condition(refer to screenshot).
company=ca60733fdbc75340b828f5461d9619f2^service_offering.cost_center=3cf0306fdbcf9700a9e4f3d61d9619fc^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^NQcaller_id=javascript:gs.getUserID()^ORu_on_behalf_of=javascript:gs.getUserID()^ORu_business_user=javascript:gs.getUserID()
company=ca60733fdbc75340b828f5461d9619f2^service_offering.cost_center=3cf0306fdbcf9700a9e4f3d61d9619fc^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^NQcaller_id=javascript:gs.getUserID()^ORu_on_behalf_of=javascript:gs.getUserID()^ORu_business_user=javascript:gs.getUserID()
Issue is whenever I put ^NQ within addEncodedQuery in Query Business rule, it stops working. Is there any alternate solution for this?
Thanks,
KUMAR
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2019 04:41 AM
^NQ is not supported in BR query rules. Since your B query only consists of OR queries, you can simply include that into your A query with additional OR conditions.
^NQ is only ever necessary if you have multiple queries each of which consist of multiple AND subconditions that have to be OR'ed together, which is not the case here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2019 02:56 AM
did you try with addOrCondition()
sample code
var gr = new GlideRecord('incident');
var qc = gr.addQuery('category', 'Hardware');
qc.addOrCondition('category', 'Network');
gr.addQuery('number','INC0000003');
gr.next();
gr.number;
gs.info(gr.getEncodedQuery());
adding doc link here for further information .
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=GQC-addOrCondition_S_S_O
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2019 03:11 AM
Try This
var qc = current.addEncodedQuery('company=ca60733fdbc75340b828f5461d9619f2^service_offering.cost_center=3cf0306fdbcf9700a9e4f3d61d9619fc^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744');
qc.addOrCondition('caller_id',gs.getUserID);
qc.addOrCondition('u_on_behalf_of',gs.getUserID);
qc.addOrCondition('u_business_user',gs.getUserID);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2019 03:59 AM
I tried with addOrCondition. It is not working.
system doesnot take or condition after encoded query.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2019 04:08 AM
did you try with the sample example which i had mentioned in my reply.
try to break that encodedquery to addQuery() and then addOrCondition() and see if it's working or not.