Announcing the Global SNUG Board of Directors. Learn more here
12-04-2017 04:23 AM
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.
12-04-2017 04:41 AM
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.)
12-04-2017 04:43 AM
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.
Best Regards,
Varad
Please hit correct/helpful/like based on response's impact