Blog

Finding the sys_id of a record

ServiceNow has the sys_id of fields sort of hidden.  However there are a couple of tricks to get that sys_id field.

ODBC Driver

If you are using the ServiceNow ODBC Driver and a reporting tool, you can pull the sys_id field information easily.  However the inconvenient part is getting the ODBC driver setup.  It is often easier to just use ServiceNow to find sys_ids.

Right Click

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 whose sys_id is required.
2. Right click the header bar and select Copy Sys_id

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

Also the sys_id can be viewed in the information bar of the browser simply by hovering over a link to the record.

Client side Javascript

Add a onLoad Client Script to show a sys_id

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

Server Side Javascript

The sys_id value of a record can be found in a business rule (or any other server-side JavaScript) by dot-walking from the GlideRecord:

var id = current.sys_id;

Background Script

The sys_id value of a record can be found in a background script.  Here is an example:

findCISysID();
function findCISysID(){
grCI = new GlideRecord('cmdb_ci');
grCI.query();
while (grCI.next()){
gs.print('CI Name: '+grCI.name+ ', Sys ID: ' +grCI.sys_id);
}
}

Export CSV

If you are using the Dublin version of ServiceNow or higher , 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 whose sys_id is required.
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://<your_instance>.service-now.com/incident_list.do?sysparm_query=active%3Dtrue%5Ecategory%3DApplication&CSV&sysparm_default_export_fields=all