Blog

Ten Methods to Find SysID

Each record in ServiceNow is identified by a unique 32-character GUID (Globally Unique ID) called a sys_id.

As a ServiceNow administrator, finding the sys_id of a record is important when writing a script, workflow, flow, or many other development tasks.

Here are ten different methods to find the sys_id of a record in ServiceNow:

1. 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

  1. Navigate to the record where you are looking for a sys_id

  2. Right click the header bar and select Copy sys_id. Alternately you can also click the Hamburger > Copy sys_id

Example Copy sys_id

2. XML

To get a sys_id from xml

  1. Navigate to the record where you are looking for a sys_id

  2. Right click the header bar and select Show XML. Alternately you can also click the Hamburger > Show XML

  3. Scroll down in the XML and find the sys_id line

Example XML

Example XML

3. 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

  1. Navigate to the record where you are looking for a sys_id

  2. 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

4. CLIENT SIDE JAVASCRIPT

You can also get the sys_id from a client-side script

Add a onLoad Client Script to show a sys_id

function onLoad() {
var incSysid = g_form.getUniqueValue();
alert(incSysid);
}

5. 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');

6. BACKGROUND SCRIPT

The sys_id value of a record can be found in a background script.  

How to use a Background Script to retrieve a sys_id

Test in a development instance first!

  1. Login as an admin

  2. Go to System Definition > Scripts - Background

  3. 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'));
	}
})();

Example Background script result

7. 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

  1. Navigate to the list of records where you want to find the sys_id

  2. Build your filter

  3. Right click the Filter, and select Copy URL

  4. Paste the URL into a new browser window

  5. Add &CSV&sysparm_default_export_fields=all to the end of the URL

  6. A CSV file with all fields AND the sys_id is exported.

Example URL

https://dev79971.service-now.com/nav_to.do?uri=%2Fincident_list.do%3Fsysparm_query%3Dactive%3Dtrue%5Ecategory%3Dinquiry%26sysparm_first_row%3D1%26sysparm_view%3D

Example CSV Export

8. Easy Import

Here is a creative way to use the Easy Import Template to export the sys_id data you are looking for.

  1. Navigate to the list of records where you want to find the sys_id

  2. Build your filter

  3. 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

  4. Click Create Excel Template

  5. Click Download

  6. Open the Excel Spreadsheet

  7. Select Page 1

  8. In the far-right column, the sys_id is shown

Example Easy Import Template

9. 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.

Example ODBC Driver SQL Query

10. 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

Example REST Query