Exporting Data (Including Sys ID) - ben-vargas/servicenow-wiki GitHub Wiki

Sometimes you need to export records from ServiceNow and include the sys_id field for debugging, integrations, or detailed reporting. While there are multiple approaches, one of the simplest methods—if it works on your instance—is to use sysparm_default_export_fields=all, which attempts to include all fields (including sys_id).

If that doesn’t work for you, don’t worry. Below are several alternative methods, from quick URL tweaks to more permanent configuration options.

Supported Export Formats

ServiceNow supports various formats for exporting list data directly from the user interface:

  • CSV
  • Excel
  • XML
  • JSON
  • PDF
  • RSS

For details on the native export capabilities and formats, refer to the official [ServiceNow Documentation on List Exports](https://www.servicenow.com/docs/csh?topicname=c_ExportListData.html&version=latest).

1. Using sysparm_default_export_fields=all

Before trying more complex options, test whether your instance allows including sys_id by using sysparm_default_export_fields=all.

Steps:

  1. Navigate to a list view of the records you want to export (e.g., customer_account).
  2. Append &sysparm_default_export_fields=all to the list URL along with your desired format. For example:
    https://<your_instance>.service-now.com/customer_account_list.do?CSV&sysparm_default_export_fields=all
    
  3. Load this URL. If your instance supports this parameter as intended, you should see sys_id included in the exported data.

If this doesn’t produce the desired results, move on to the more explicit methods below.

2. Using sysparm_fields to Enumerate Desired Fields

If sysparm_default_export_fields=all doesn’t include sys_id for your table or version, you can explicitly define which fields to export.

Steps:

  1. Navigate to a list view of the records you want to export.
  2. Right-click the header and select Export > Excel (or the format of your choice).
  3. Check the URL after clicking Export but before it completes. You’ll notice a parameter like:
    ...&sysparm_fields=number,short_description,category,...
    
  4. Simply add sys_id to that list:
    ...&sysparm_fields=sys_id,number,short_description,category,...
    
  5. Press Enter to load the modified URL, which should trigger the export with the sys_id included.

Example Modified URL:

https://<your_instance>.service-now.com/incident_list.do?CSV&sysparm_query=active=true&sysparm_fields=sys_id,number,short_description

This approach is quick and doesn’t require permanent configuration changes.

3. Editing a List View to Add sys_id for Export

If you frequently need sys_id in exports, consider adding it directly to the list view configuration.

Steps:

  1. Open the list view of the table you’re working with (e.g., Incidents).
  2. Click the gear icon (Configure list layout).
  3. Add sys_id to the selected fields.
  4. Save the configuration.

Now, when you export the list (via Right-click on header > Export > format), the sys_id field will be included automatically.

Pro Tip: Create a separate list view specifically for exporting so you don’t clutter your normal working views.

4. Creating a Database View

If you’re working across multiple tables and need sys_id or other fields from related records, consider using a Database View. A database view allows you to join multiple tables and export the combined dataset in your preferred format.

Steps:

  1. Navigate to System Definition > Database Views.
  2. Click New to create a new view.
  3. Add your primary table and any joins you need.
  4. Ensure sys_id is one of the fields in the view definition.
  5. Once saved, navigate to the view’s list and export it.

5. Other Tips & Best Practices

  • Scripting with GlideRecord:
    For fully customized exports, you can write a script within a Scheduled Script Execution or Script Include to query records via GlideRecord, then format and export them as CSV or Excel-friendly data.

    Example (Server-side script):

    var gr = new GlideRecord('incident');
    gr.addQuery('active', true);
    gr.query();
    var csvArray = ['sys_id,number,short_description'];
    while (gr.next()) {
      csvArray.push(gr.getValue('sys_id') + ',' + gr.getValue('number') + ',' + gr.getValue('short_description'));
    }
    gs.info(csvArray.join('\n'));
    

    You can copy the output from the logs and paste it into Excel.

  • Personalized Views:
    Consider creating a dedicated “Export” view that includes all your commonly needed fields. Switch to this view before exporting, and you’ll get everything you need in one shot.

  • Check Access Controls:
    Ensure the fields you’re trying to export, including sys_id, aren’t restricted by ACLs. If you don’t have permission, they might not show up in the export.

Summary

  • sysparm_default_export_fields=all: Test this first to see if it automatically includes sys_id.
  • URL Method (sysparm_fields): Quick and flexible—manually specify sys_id if all doesn’t work.
  • Configure List Layout: Perfect for recurring needs—add sys_id to your list configuration.
  • Database Views: Ideal for complex joins and multiple related tables.
  • Scripting: Ultimate flexibility for advanced or scheduled exports.

Experiment with these methods and pick the one that best fits your workflow!