A unique 32-character GUID identifies each record in ServiceNow (Globally Unique ID) called a sys_id.
sys_id of a record is important when writing a script, workflow, or other development tasks.
Here are ten different methods to find the sys_id of a record in ServiceNow:
-
Right-click or hamburger
You can right-click the header bar of most forms and find the sys_id.-
To get a sys_id from the header bar:
-
Navigate to the record where you are looking for a sys_id.
-
Right-click the header bar and select Copy sys_id. Alternately you can also click the Hamburger > Copy sys_id
-
-
-
XML
-
To get a sys_id from XML
-
Navigate to the record where you are looking for a sys_id
-
Right click the header bar and select Show XML. Alternately you can also click the Hamburger > Show XML
-
Scroll down in the XML and find the sys_id line
-
-
- URL
Since the sys_id of a record is always part of the URL for a link to that record, it is possible to retrieve the sys_id by viewing the URL.
-
To get the sys_id from XML
- Navigate to the record where you are looking for a sys_id
-
Right-click the header bar and select Copy URL. Alternately you can also click the Hamburger > Copy URL
For example, an Incident with the following URL:
https://<instance name>.service-now.com/nav_to.do?uri=incident.do sys_id=23dc968f0a0a3c1900534f399927740e
-
The sys_id is : 23dc968f0a0a3c1900534f399927740e
-
-
- Client side JavaScript
You can also get the sys_id from a client-side script
- Add an onload client script to show a sys_id
function onLoad() {
var incSysid = g_form.getUniqueValue();
alert(incSysid);
}
- Add an onload client script to show a sys_id
- Server side JavaScript
The sys_id value of a record can be found in a business rule (or any other server-side JavaScript)
var id = current.getValue('sys_id');
- Background Script
The sys_id value of a record can be found in a background script.
Note: Test in a development instance first!- How to use a background script to retrieve a sys_id
-
Login as an admin
-
Go to System Definition > Scripts - Background
-
Paste a script similar to this and click Run Script
(function() {
var grCI = new GlideRecord('cmdb_ci');
grCI.addQuery('name','=','SAP WEB03’);
grCI.query();
while (grCI.next()){
gs.print('CI Name: '+grCI.getValue('name')+ ', Sys ID: ' +grCI.getValue('sys_id'));
}
})();
-
- How to use a background script to retrieve a sys_id
- Export CSV
By adjusting the url of a record, you can add this URL Parameter to export the sys_id and all fields to CSV
&CSV&sysparm_default_export_fields=all
- How to use this parameter
-
Navigate to the list of records where you want to find the sys_id
-
Build your filter
-
Right-click the Filter, and select Copy URL
-
Paste the URL into a new browser window
-
Add &CSV&sysparm_default_export_fields=all to the end of the URL
-
A CSV file with all fields AND the sys_id is exported.
-
- How to use this parameter
- Easy import
Here is a creative way to use the Easy Import Template to export the sys_id data you are looking for.
-
Navigate to the list of records where you want to find the sys_id
-
Build your filter
-
Right click the header bar and select Import. Alternately you can also click the Hamburger > Import
-
Do you want to insert or update data? Update
-
Do you want to create an Excel template to enter data ? True
-
Include all fields in the template? True or False, your choice
-
-
Click Create Excel Template
-
Click Download
-
Open the Excel Spreadsheet
-
Select Page 1
-
In the far-right column, the sys_id is shown
-
- ODBC Driver
If you are using the ServiceNow ODBC Driver and a reporting tool, you can pull the sys_id field information easily.
-
Install the ODBC Driver. This guide is helpful. After you install the ODBC Driver, you can run a SQL query and depending on the query, the sys_id can be exported.
-
- REST API
If you are using the ServiceNow Rest API, you can also pull sys_ids
Destination: GET: <your_instance>.service-now.com/incident.do?JSONv2&sysparm_action=getRecords&sysparm_query=number=INC0000059
Authentication (Basic) Username/Password
Headers: Content-Type | application/json
Check this link (external): https://www.servicenowelite.com/blog/2020/9/29/ten-methods-to-find-sysid?rq=sys_ID