Complex query with and and or conditions

jean-lucchatton
Kilo Guru

Hello,

I'im trying to create a complex query with and and or conditions.

What is working is a mix of and and or like that : (U OR V) AND (W OR Y OR Z).

What is need is a mix like this : (A AND B) OR C OR D OR E

My code :

var qc = current.addQuery('locationIN' + locations);

qc.addQuery('u_visible_by_external_provider', true);

var qr =   current.addOrCondition('assignment_group', IN', Usergroups);

qr.addOrCondition('caller_id', u);

qr.addOrCondition('opened_by', u);

But is don't work

I've also tried with and encode query but there is a know bug by ServiceNow (https://community.servicenow.com/message/963069#963069 and

ServiceNow KB: PRB647484: Using operator (^NQ) in encoded queries causes incorrect reference links i... ).

Could you help me please ?

Jean-Luc

8 REPLIES 8

pbo
Mega Expert

Hi Jean-Luc,



I have the same requirement.



Did you find a way to solve it and implement a query like (A AND B) OR (C AND D) in a query BR (ie without NQ operator)



Merci




Hi Patrick,



No, I didn't find a solution and gave up ! I've simplified my needs.


Dommage !



The only solution that I found is to rewrite query like (A OR B) AND (C OR D)   to



(A or C) AND (A Or D) AND (B OR C) AND (B OR D)


agopalrao
Mega Contributor

The only solution I found is by using encoded query. Even I would like to know if anyone know the answer for it.