Union Of conditions

suyoga
Tera Expert

Hey Folks,

 

I need help with creating union of condition, I have a relationships(Related List) on incident table which have criteria something like below:

 

current.addEncodedQuery('caller_id=' + parent.caller_id + '^ORu_behalf_of=' + parent.caller_id + '^ORcaller_id=' + parent.u_behalf_of + '^ORu_behalf_of=' + parent.u_behalf_of + '^sys_id!=' + parent.sys_id + '^sys_created_onONLast 60 days@javascript:gs.beginningOfLast60Days()@javascript:gs.endOfLast60Days()');  
 
Recommendation from servicenow team is to remodel this and have it in UNION and go away with OR condition(underlined) in above condition, I am looking for recommendations on how to go away with OR condition.
1 ACCEPTED SOLUTION

Hey @Ankur Bawiskar , I could not get that to work however I tried realigning of query and that helped reduce the timing, so new criteria looks something like below, this brought down timing to 1/3rd:

current.addEncodedQuery( 'sys_id!=' + parent.sys_id + '^sys_created_onONLast 60 days@javascript:gs.beginningOfLast60Days()@javascript:gs.endOfLast60Days()' + ('caller_id=' + parent.caller_id + '^ORu_behalf_of=' + parent.caller_id + '^ORcaller_id=' + parent.u_behalf_of + '^ORu_behalf_of=' + parent.u_behalf_of ));  

View solution in original post

7 REPLIES 7

@suyoga 

I just updated the above script

Note: I haven't tested it, please test it in background script

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@suyoga 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hey @Ankur Bawiskar , I could not get that to work however I tried realigning of query and that helped reduce the timing, so new criteria looks something like below, this brought down timing to 1/3rd:

current.addEncodedQuery( 'sys_id!=' + parent.sys_id + '^sys_created_onONLast 60 days@javascript:gs.beginningOfLast60Days()@javascript:gs.endOfLast60Days()' + ('caller_id=' + parent.caller_id + '^ORu_behalf_of=' + parent.caller_id + '^ORcaller_id=' + parent.u_behalf_of + '^ORu_behalf_of=' + parent.u_behalf_of ));