ServiceNow provides a number of ways to export data from the platform. All of these methods are simple to use, but something that isn’t always obvious is how to include the Sys ID value associated with a record in the export.
Depending on how you plan to use the exported data, having the Sys ID is important. If you plan to do any kind of reconciliation or bring that data back into the platform in the future, having this value is critical.
In this post, I’m going to cover several ways to get data out of the platform with Sys IDs.
Using Export Sets
Prior to Jakarta, it was not possible to add the Sys ID field to an export definition. Starting with the Jakarta release, Sys ID is available. Simply add it to the list of selected fields like any other field.
Using the CSV Web Service
The CSV Web Service can be used as an alternative to the Export > CSV context menu. The context menu will only export the values shown in the current list view, and since you cannot add Sys ID as a column in a standard list view, you cannot export the Sys ID value this way. Use the CSV web service instead.
Before the term “web service” scares you away, you can use this functionality directly from your browser. No need to build some kind of API client.
Construct a URL
The simplest way to get started with the CSV Web Service is to append the ?CSV URL parameter to any table. For example, try navigating to this URL in your browser (replace the instance name with your own, don’t try this in production):
Your browser will download a file containing all incident records.
Add the Sys ID to the output using sysparm_default_export_fields
By default, the CSV Web Service will only export the fields defined in the default view. You can also specify an alternate view such as ess, but since you cannot add the Sys ID column to a view, you must specify a different parameter:
This parameter tells the web service to export all fields from the table including the Sys ID. Beware that this also brings every other field along with it. Example URL:
And the result:
A few other notes
This post focuses on export methods that can be initiated automatically. Export Sets can be scheduled, and the CSV web service can be consumed by an external system.
There are other ways you can get Sys IDs out:
- Use the Export > XML context menu from any list view. This will export the entire record, including the Sys ID.
- Starting with Jakarta, use the Export > JSON context menu from any list view. This is similar to Export XML, but returns a JSON payload instead.
Share this post