IN operator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2010 12:07 PM
Has anyone seen how to emulate the IN operator of a SQL where clause with addQuery() method?
For example gr.addQuery('sys_id','IN','val1,val2,val3...');
IN or IS ONE OF and NOT ONE OF are not explained here http://wiki.service-now.com/index.php?title=Querying_a_Service-now_Table_from_Javascript#Available_JavaScript_Operators
I can create URL using IN (IS ONE OF in filter) using this construct sysparm_query=sys_idIN0331ddb40a0a3c0e40c83e9f7520f860%2C032ebb5a0a0a3c0e2e2204a495526dce, but would like to use addQuery() in a Script for UI page , Business Rule, or Scheduled Job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2010 01:32 PM
I think you just need to use...
gr.addQuery('sys_idIN0331ddb40a0a3c0e40c83e9f7520f860,032ebb5a0a0a3c0e2e2204a495526dce,...');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2010 02:00 PM
Yes it does. Thanks a million. I also found that this works too.
ci.addQuery('sys_id','IN','0331ddb40a0a3c0e40c83e9f7520f860,032ebb5a0a0a3c0e2e2204a495526dce');
They key to this is not to attempt to build an array object to hold the test values or enclose inside () like a SQL construct. e.g. "('0331ddb40a0a3c0e40c83e9f7520f860','032ebb5a0a0a3c0e2e2204a495526dce',...)" does not work for the 3rd param.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2010 10:23 AM
It doesn't help in the URL, but FYI, you can also pass an array variable as the 3rd parameter.