- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 04:37 AM
Hi Community
I have a question about building queries in knowledge query using both IR_AND_OR_QUERY and ^NQ
When building the query everything works fine except that when adding ^NQ nothing is shown.
Both parts of the query works separetly but when using the ^NQ non of them works.
The first part the "groups" and "comp" are arrays and the "available for" fields glidelists
I want to return results where the user is either member of a chosen group or the user have relation to a chosen company OR articles where both the lists are empty
var str = current.getEncodedQuery().toString();
var search2 = str.search('IR_AND_OR_QUERY');
var subStr = str.substring(search2, str.indexOf('^', search2));
current.addEncodedQuery('active=true^workflow_state=published^u_available_forLIKE' + groups + '^ORu_available_for_companiesLIKE' + comp + '^language=javascript:gs.getUser().getLanguage()^' + subStr +
'^NQactive=true^workflow_state=published^language=javascript:gs.getUser().getLanguage()^u_available_for_companiesISEMPTY^u_available_forISEMPTY^' + subStr);
So the question is, if im doing something wrong with the search somehow that i cant see myself or maybe i misses some functionality with IR_AND_OR_QUERY and ^NQ
Thanks
Simon
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 10:23 PM
The conclusion on this one is to add en encoded query followed by an addQuery with the IR_AND_OR_QUERY
That seems to work even when using ^NQ in the encoded query so IR_AND_OR_QUERY applies to all parts of the encoded query
gr.addEncodedQuery('active=true^workflow_state=published^valid_to>=javascript:gs.daysAgoEnd(0)'); | ||
gr.addQuery('IR_AND_OR_QUERY', val); | ||
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 05:14 AM
Isnt there anyone who have an idea?
Regards
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2017 04:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 10:23 PM
The conclusion on this one is to add en encoded query followed by an addQuery with the IR_AND_OR_QUERY
That seems to work even when using ^NQ in the encoded query so IR_AND_OR_QUERY applies to all parts of the encoded query
gr.addEncodedQuery('active=true^workflow_state=published^valid_to>=javascript:gs.daysAgoEnd(0)'); | ||
gr.addQuery('IR_AND_OR_QUERY', val); | ||

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2022 03:54 AM
Hi Simon,
Fix for incorrect reference links while using (^NQ) operator : https://community.servicenow.com/community?id=view_idea&sysparm_idea_id=26aaaafddb4011d45205e6be1396...
Solution : Whenever we use ^NQ operator to join multiple queries to build a master query
we need enter ^current.getEncodedQuery() at every (^NQ) operator JOINs before moving to final encoded query
Example :
Levelcheck1 : hr_service.u_service_entity=3ef7cbc287e68d900d9f7447cebb359d
Levelcheck2 : hr_service.u_service_entity=0e974b8287e68d900d9f7447cebb35e2^assignment_group=fe7be44b8751b0100d9f7447cebb3515
Levelcheck3 : number=HRC0052382^ORnumber=HRC0001703
Mergedquery1 = Levelcheck1+^NQLevelcheck2+ "^" + current.getEncodedQuery();
Mergedquery2 = Mergedquery1+^NQLevelcheck2+ "^" + current.getEncodedQuery();
current.addEncodedQuery(Mergedquery2)
Regards,
Deepak R