Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to query multiple tables using REST web-services?

srirampappagudi
Tera Expert

Hi Experts,

how to query multiple tables using REST web-services?

Say for example I need   all the incident tickets for a particular Country or City.

I can achieve this using reporting but how can I achieve this using web-services. I want to understand how we can combine two tables and query.

Regards,

Sriram.

2 REPLIES 2

Chuck Tomasi
ServiceNow Employee
ServiceNow Employee

Hi Sriram,



This sounds like a use case for a scripted REST API. You are in complete control of what the endpoint is (parameters given, payload accepted on POST requests, how it is processed, and what the response is.)



https://developer.servicenow.com/app.do#!/document/content/app_store_doc_scripted_rest_jakarta_t_Cre...


varads_kulkarni
Giga Expert

Hi Sriram,



You can make use of the Filters to get to the query that you need. ServiceNow provides an option like Show Related Fields in filter input. Once you click on that, platform enables you to actually query the referenced tables based on the reference fields on your existing table. As in your case, location is reference field on incident table, you need to click on Show related fields, which then enables you to query on the fields available on referenced table that is location. So you could further select the input as location.country is input_value. For more information the below images might help you.



Once you run the query, right click on the rightmost query -> copy query. This query can be used in sysparm_query parameter directly to query ServiceNow.


You can actually get the necessary query using the REST API Explorer.



11.jpg


12.jpg


13.jpg



Best Regards,


Varad


Please hit correct/helpful/like based on response's impact