We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Join two Encoded queries by OR condition

Raji10
Tera Contributor

Hi All,

I am trying to combine two Encoded queries with an Or condition, example:

query 1 = 'element_id=' + converseRecord + '^valueLIKEhow^valueLIKEhelp';

query 2 ='element_id=' + converseRecord + '^valueLIKEwhat^valueLIKEissue';

gr1.addEncodedQuery(query1) || addEncodedQuery(query2);

Can anyone help how the above logic can be achieved in GlideRecord. Thank you

 

Thanks & Regards,

Rajalakshmi.

1 ACCEPTED SOLUTION

Adrian Ubeda
Mega Sage

Hi, 

use ^NQ operator between queries. This will evaluate one query and the other and will be like query 1 + OR + query 2. The syntax's like follows:

gr1.addEncodedQuery('element_id=' + converseRecord + '^valueLIKEhow^valueLIKEhelp^NQ' + 'element_id=' + converseRecord + '^valueLIKEwhat^valueLIKEissue');

If it was helpful, give positive feedback.
Thanks, 

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

View solution in original post

5 REPLIES 5

Adrian Ubeda
Mega Sage

Hi, 

use ^NQ operator between queries. This will evaluate one query and the other and will be like query 1 + OR + query 2. The syntax's like follows:

gr1.addEncodedQuery('element_id=' + converseRecord + '^valueLIKEhow^valueLIKEhelp^NQ' + 'element_id=' + converseRecord + '^valueLIKEwhat^valueLIKEissue');

If it was helpful, give positive feedback.
Thanks, 

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Prateek kumar
Giga Sage

Please take a look at below:

https://community.servicenow.com/community?id=community_question&sys_id=def3bcc6db6513042d1efb651f96...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

SantoshK1857223
Mega Sage

Hi Raji,

If you could run a filter on this table then you can add the encoded query as below:-

1) Add the filter as per your requirement:-

find_real_file.png

2) copy the query after you run this filter

find_real_file.png

3) You can add this encoded query in your script like this:-

var gr = new GlideRecord('tablename');

gr.addEncodedQuery('active=true^stateIN2,3^priority=3');

gr.query();

if(gr.next()){

}

 

Thanks
Santosh

Hemant Goldar
Mega Sage

Hi Raji,

 

Same thread has been solved before follow the link

https://community.servicenow.com/community?id=community_question&sys_id=def3bcc6db6513042d1efb651f96...

 

Please mark helpful/correct based on impact.

Kind Regards,

Hemant