how do we implement AND and OR operations in rest table api

akshay317
Kilo Contributor

HI all,

I'm new to servicenow development. I need to access Incidents table in my developer instance via REST table apis. E.g I need those records having State=Closed or State=Awaiting Problem for a specific user (name: XYZ). But I'm not able to implement OR condition in the table api query. I'm hitting the table from an external service made in javascript. Here is my query form

("get", "https://devxxx.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_fields=location,numbe...");

Here I need to implement a OR query so as to fetch records for state=Awaiting Problem.

A quick response wolud be highly appreciable. Thanks in advance.

POSTED BY AKSHAY        

1 ACCEPTED SOLUTION

santoshsahoonis
Kilo Guru

Hello,



You have to send a sysparm_query along with the link:


example:



https://xxxxx.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_query=active=true^stat...



Your link(should work now): https://devxxx.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_fields=location,numbe...




for an AND operator use ^


for an OR operator use ^OR



You can get this encoded query from any List view :



find_real_file.png




View solution in original post

5 REPLIES 5

Let me know if that answered your question. If so, please mark it as correct so that others with the same question can find it quickly in the future and that it gets removed from the Unanswered list. Thank you