How to write Query business rule for Or Condition? (^NQ) not working.

ashwanikumar
Tera Expert

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()

find_real_file.png

Issue is whenever I put ^NQ within addEncodedQuery in Query Business rule, it stops working. Is there any alternate solution for this?

Thanks,

KUMAR

1 ACCEPTED SOLUTION

Julian Hoch
ServiceNow Employee
ServiceNow Employee

^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.

View solution in original post

13 REPLIES 13

Harsh Vardhan
Giga Patron

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

Gurpreet07
Mega Sage

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);

I tried with addOrCondition. It is not working.

system doesnot take or condition after encoded query.

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.