Complex query with and and or conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2017 03:12 AM
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
Could you help me please ?
Jean-Luc
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2017 02:06 PM
What happens if you chain all your conditions?
current.addQuery('locationIN' + locations).
addQuery('u_visible_by_external_provider', true).
addOrCondition('assignment_group', IN', Usergroups).
addOrCondition('caller_id', u).
addOrCondition('opened_by', u);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 11:09 PM
It doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 02:47 AM
Hi Jean,
When i need to apply any such complex query i try to add filters, copy query from there and use it as EncodedQuery in my GlideRecord.
Now what you need here is a scenario like this
- [Active] [is] [true] AND [Category] [is] [Hardware]
- Top level OR condition
- [Active] [is] [false] AND [Category] [is] [Software]
Here is a link that Explains how you can use the BIG AND and BIG OR to make these queries.
http://wiki.servicenow.com/index.php?title=Using_Filters_and_Breadcrumbs#Using_OR_Conditions
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 03:05 AM
Hi Anurag,
Thanks for your answer but I doesn't work. If you read carefully my original post you will see the reference to the documented ServiceNow bug
Jean-Luc