Search code examples
restservicenow

Retrieving request information form ServiceNow via API


Within our ServiceNow installation we have created a simple new Request form with two text input values. The form looks something like this:

+--------------------------------------------------------+
| Get new Computer-request                               |
+--------------------------------------------------------+
| model: <text input field>                              |
+--------------------------------------------------------+
| organization: <text input field>                       |
+--------------------------------------------------------+

When a new request has been created using this form, we can retrieve all relevant information using the ServiceNow table API, by querying the following tables:

  • sc_req_item
  • sc_item_option_mtm
  • sc_item_option
  • sc_cat_item

When issuing these REST calls we have to use several filters to navigate from one table to another and to only get the most recent items and only the request items within our service catalog category.

Ideally, we would like to save the entire request (timestamp, user, input values) as a JSON String within a single table. This way, we would only have to query this single table to retrieve all relevant information for a request.

Does ServiceNow support generating/saving a single JSON file from request form?

Any help is highly appreciated.


Solution

  • After some reading about scripted REST Apis as suggested by Joey's answer, I have created some code to do the table joining and filtering on ServiceNow.

    The code is here: https://github.com/1123/ServiceNowRequestsApi