- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2016 09:25 AM
I am trying to add a NOT equals conditional statement to this example URL. I want all incidents from a particular user where the state does NOT equal 6. Is there any way to do this? I can't seem to find any helpful service-now REST API condition help sheets/examples.
Any thoughts/advise is appreciated! Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2016 09:46 AM
Hi Michael,
Use an encoded query:
api/now/table/incident?sysparm_query=assigned_to%3D5137153cc611227c000bbd1bd8cd2007^state!=7
This is specified in the documentation here:
You should use an encoded query in this case because URL parameters do not support the full semantics of a filter. URL params are limited to key:value pairs (assigned_to = some_value) or just keys (&XML for instance, to view the XML of a record in ServiceNow):
/incident.do?sys_id=i8d6353eac0a8016400d8a125ca14fc1f&XML
But there is no concept of a negation in URL parameters. That has to be done by parsing the *value* of a specified parameter, and the system being smart enough to turn that into a meaningful statement. So the URL:
api/now/table/incident?assigned_to=5137153cc611227c000bbd1bd8cd2007&state!=6
will be parsed as "assigned_to is some user" AND "'state!' is 6".
By using an encoded query, you get the full range of ServiceNow's filtering ability.
Thanks,
Cory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2016 09:46 AM
Hi Michael,
Use an encoded query:
api/now/table/incident?sysparm_query=assigned_to%3D5137153cc611227c000bbd1bd8cd2007^state!=7
This is specified in the documentation here:
You should use an encoded query in this case because URL parameters do not support the full semantics of a filter. URL params are limited to key:value pairs (assigned_to = some_value) or just keys (&XML for instance, to view the XML of a record in ServiceNow):
/incident.do?sys_id=i8d6353eac0a8016400d8a125ca14fc1f&XML
But there is no concept of a negation in URL parameters. That has to be done by parsing the *value* of a specified parameter, and the system being smart enough to turn that into a meaningful statement. So the URL:
api/now/table/incident?assigned_to=5137153cc611227c000bbd1bd8cd2007&state!=6
will be parsed as "assigned_to is some user" AND "'state!' is 6".
By using an encoded query, you get the full range of ServiceNow's filtering ability.
Thanks,
Cory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2017 10:07 AM
The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Table API
Visit http://docs.servicenow.com for the latest product documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2018 04:10 AM
Hi
I have a similiar question.
How can I add OR statements by using the following REST API URL:
https://company.service-now.com/api/now/stats/incident?sysparm_count=true&assignment_group=Grup-Name&state=2
I tried the following way:
https://company.service-now.com/api/now/stats/incident?sysparm_count=true&assignment_group=Grup-Name&state=2^OR_state=3
Thanks in adwance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 02:11 PM
Have you tried the | (for the OR operator), that is typically used in logical operations:
^ = AND
! = NOT
| = OR