Exporting and converting records into complex data types
Summarize
Summary of Exporting and converting records into complex data types
This guide explains how ServiceNow customers can export records from tables and convert them into complex data types such as JSON, XML, PDF, CSV, and XLS using HTTP GET requests with specific URL parameters. It also covers how to filter records during export and how to directly import certain data types back into tables using POST requests.
Show less
Key Features
- Exporting Records: Use GET requests with URL parameters appended to the table URL to retrieve records in desired formats. For example, appending
?XLSto the incident table URL exports records as an Excel file. - Supported Data Types and Parameters:
- CSV (
CSV) - Excel (
XLS,EXCEL,XLSX) - JSON (
JSONv2) - PDF (
PDF) - RSS (
RSS) - XML (
XML,XSD,SCHEMA)
- CSV (
- Filtering Results: Use URL filters like
sysparmqueryto export specific subsets of data (e.g., only active records) andsysparmviewto specify list views controlling the fields included in exports. - PDF Export Specifics: When exporting PDFs, distinguish between exporting a list (
listsuffix) and a single record (requires specifying the record’ssysid). - Unload Format for XML: Use
useUnloadFormat=trueto export XML in a format suitable for re-import into tables. - Direct Import Support: CSV, Excel, and JSON files can be POSTed directly to tables if the file headers match the table’s field columns.
Practical Usage Examples
- Export active incident records as Excel:
https://instancename.service-now.com/incident.do?XLS&sysparmquery=active=true - Export incident records as PDF using a specific view:
https://instancename.service-now.com/incident.do?PDF&sysparmview=ess - Export XML in unload format for later import:
https://instancename.service-now.com/incident.do?XML&useUnloadFormat=true
Key Outcomes
- Enables flexible exporting of table data in multiple formats suitable for reporting, data sharing, or integration.
- Allows filtering of exported data to focus on relevant records and fields.
- Simplifies importing data by allowing direct POST of compatible CSV, Excel, and JSON files into tables.
- Supports automation and integration scenarios by leveraging standard HTTP requests and URL parameters.
Use URL parameters to export table records and convert them into complex data types, such as JSON, XML, PDF, CSV, and XLS.
Exporting records as complex data types
You can use an HTTP GET request to retrieve records from a table and put
them in a specified format. For example, use the PDF parameter in a
GET request to export records from a table as PDF files; use the
XLS parameter to export records from a table as XLS files. For
example, to retrieve a list of incident records as XLS files, issue an HTTP
GET using the following URL:
https://instance_name.service-now.com/incident.do?XLS. The file returned
is incident.xls. incident.do is basically a
GET that returns a list of the records from the incident table. The
XLS parameter converts those records into XLS files.
The general syntax is:
https://<serviceNow-instance-name>/<table-name>.do?<Data-type-parameter>
URL parameters
| Data type | Parameter | Valid filters | Directly POST to table? |
|---|---|---|---|
| CSV | CSV | sysparm_query, sysparm_view | Y |
| Excel | XLS, EXCEL, XLSX | sysparm_query, sysparm_view | Y |
| JSON | JSONv2 | Various. See JSON data retrieval API. | Y |
| sysparm_query, sysparm_view | N | ||
| RSS | RSS | sysparm_query, sysparm_view and more. See Limiting results with a view. | N |
| XML | XML, XSD, SCHEMA | sysparm_query, useUnloadFormat | N |
For more information about retrieving and converting table records into the JSON file format, see JSONv2 Web Service.
For more information about retrieving and converting table records into the RSS file format, see RSS feed generator.
Converting records to PDFs
For PDF export, there is a distinction between targeting a table and targeting its list. To generate a PDF of a list of records, suffix the target with _list. To target a single record, you must specify the sys_id parameter to identify the record for which you are generating the PDF.
Filters
All URL parameters work with filters that enable you to export a subset of table records.
For example, sysparm_query=active=true in a GET request
exports only active records. The following example exports only active incident records in
an Excel format:
https://instance_name.service-now.com/incident.do?EXCEL&sysparm_query=active=true.
The general syntax is:
https://<serviceNow-instance-name>/<table_list>.do?<Data-type-parameter>&<filter>
- sysparm_query—Filters the data using the encoded query before exporting files, for
example,
sysparm_query=active=trueexports only active records. - sysparm_view—Specify the name of a list view to control which fields are returned. For
example, to return the ESS view, use
sysparm_view=ess. - useUnloadFormat—Indicates that the XML format returned is an unload format. The unload
format is the same format you get when, from a list in the UI, you select Export > XML >
... You can import unload-formatted XML files back into the tables. To enable the unload
format from a URL, use the
useUnloadFormat=trueURL parameter, for example,https://instance_name.service-now.com/incident.do?XML&useUnloadFormat=true.
Example GET queries
| Data type | Example query |
|---|---|
| CSV | https://instance_name.service-now.com/incident.do?CSV&sysparm_query=active=true |
| Excel | https://instance_name.service-now.com/incident.do?XLS&sysparm_query=active=true |
https://instance_name.service-now.com/incident.do?PDF&sysparm_view=ess |
|
| RSS | https://instance_name.service-now.com/incident.do?RSS&sysparm_view=ess |
| XML | https://instance_name.service-now.com/incident.do?XML&sysparm_query=active=true |
Returned files
GET queries return records from a table in the format specified in the request. For example, a query that uses the XLS parameter returns a table record in a file with the .xls extension.
The Content-Disposition header in the response displays the file name and extension of the returned file. The file name is based on the table you export from, such as incident.xls, incident.pdf, or incident.xml.
Exporting data into tables
- CSV
- Excel
- JSON
The file headers must match the field columns in the targeted table. For more information, see Post CSV or Excel files directly to an import set.