Use OR statements in REST API URL

Luca14
Giga Contributor

 

Hi 

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

1 ACCEPTED SOLUTION

Hi Luca,

 

Your best bet when trying to learn how to write more complex query statements is to view a list on the table of interest, and then use the filter icon at the top to build out your query as desired.  Once you have that created, you can simply right-click on the last condition in the filter breadcrumbs and choose "Copy query" to get a properly formatted encoded-query statement.

 

find_real_file.png

 

(copied to clipboard): assignment_group=9939670d6f30b508a4c2211bbb3ee48d^stateNOT IN2,3

 

Give that a try,

-Brian

View solution in original post

16 REPLIES 16

Hi Luca,

 

Your best bet when trying to learn how to write more complex query statements is to view a list on the table of interest, and then use the filter icon at the top to build out your query as desired.  Once you have that created, you can simply right-click on the last condition in the filter breadcrumbs and choose "Copy query" to get a properly formatted encoded-query statement.

 

find_real_file.png

 

(copied to clipboard): assignment_group=9939670d6f30b508a4c2211bbb3ee48d^stateNOT IN2,3

 

Give that a try,

-Brian

Thank you Brian this worked for me 😉 

Together with Mike's input to use 

sysparm_count=true

at the end of a querry I was able to retrieve the desired values.