- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-02-2019 03:27 PM
Hi,
I am new to Service Now development and do not have any historical knowledge with respect to internals and table structure. Can anyone provide a brief summary of the steps involved to obtain a request, its associated ritm's and enumerate their tasks?
I will know the request # to start, so after reading the api reference, I can easily obtain that data:
curl "https://instance.service-now.com/api/now/table/sc_request?number=REQ0000000" \
--request GET \
--header "Accept:application/json" \
--user 'xxx':'yyy' --silent |jq .
However, from that, I am not clear on how to infer the sc_req_item. Presumably, I construct a query on that table that constrains the items to those related to the sys_id of the request?
And lastly, whatever strategy is required there, I assume it is similar to enumerate the tasks for the a given item once I decide which one is of interest?
Thanks for any guidance!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-03-2019 06:03 AM
It sounds like you've got the process down if you're using the table api. The sc_req_item table has a field that references the sc_request table called request. The sc_task table has a field that references the sc_req_item table called request_item. Passing the appropriate sys_ids into those fields will give you the lists of items and tasks in the response. You can also use the number of the item rather than the sys_id if you want to by doing something like request.number=REQ0000000 from the item or even request_item.request.number=REQ0000000 from the task.
I would use the REST API Explorer we provide to get comfortable with the rest api overall as it gives you a GUI for building queries you can then use.
Another option would be to write your own Scripted REST API where you would execute some server side JS in ServiceNow when a custom endpoint is hit and return all of the information you're looking for in one rest call. The learning curve on this what is a bit higher due to the SN JS you'd have to write.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-03-2019 06:03 AM
It sounds like you've got the process down if you're using the table api. The sc_req_item table has a field that references the sc_request table called request. The sc_task table has a field that references the sc_req_item table called request_item. Passing the appropriate sys_ids into those fields will give you the lists of items and tasks in the response. You can also use the number of the item rather than the sys_id if you want to by doing something like request.number=REQ0000000 from the item or even request_item.request.number=REQ0000000 from the task.
I would use the REST API Explorer we provide to get comfortable with the rest api overall as it gives you a GUI for building queries you can then use.
Another option would be to write your own Scripted REST API where you would execute some server side JS in ServiceNow when a custom endpoint is hit and return all of the information you're looking for in one rest call. The learning curve on this what is a bit higher due to the SN JS you'd have to write.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-03-2019 07:10 AM
Thanks for the insight Brad, I was unaware of the relational functionality available and that will greatly simplify my needs.