FileExport

Most people are probably aware of the ability of a ServiceNow instance to export data into different file formats using a RESTful “GET” call to the instance. In essence, you specify the table_name.do and tack on a format identifier and “voila!” a file is downloaded to your computer with data from the instance.

For information on the various web services that can do this, and how each one behaves, check out the following wiki articles:

There have been a few times when it would be helpful to have a Runbook/Orchestration activity that would allow my workflow to deliver a data export file to a machine either on a scheduled basis or part of a designed process. CrossFuze Solutions, offers a scheduled data extract, which is very handy. While this method has a similar outcome, the use case is geared for an Orchestration script.

Screenshot_3_25_13_11_31_AM

This activity is based off of the Powershell runbook libraries and thus requires a windows computer. Linux computers are easier as you can just use a simple “wget” command. However, given Powershell’s capabilities, this is doable with very little effort.

Once you upload this activity by loading the update set listed in this article, you can leverage it through the Workflow Editor application in ServiceNow. Simply browse to: “Runbook – PowerShell”->”Export SN Data Windows”. Drag that activity onto your workflow editor.

Screenshot_3_25_13_11_35_AM

Here is a quick rundown on the fields:

  • Hostname: The computer that will execute and store the export file. For the MID Server executing this, just use 127.0.0.1.
  • Instance URL: The URL of the ServiceNow instance you will be exporting from
  • ServiceNow User Name: The user account in ServiceNow that will do the authentication
  • ServiceNow User Password: The ServiceNow user’s password
  • Format: One of the supported export formats
  • Resource: This is the ServiceNow table name, database view name, or report name (note, while all formats support the tables, they don’t all support views or reports – see the wiki documentation for each format.
  • Query Paramters: A name value pair of URL query parameters for the request. Each pair should be on its own line.
  • Output File: The location and name of the output file containing the export data.

To demonstrate this, I’ll show you how to enter workflow activities for the following scenario:

Get all Priority 1, Active Incidents into an XML file

Screenshot_3_25_13_2_42_PM

  • Hostname: 127.0.0.1 (I just want it to execute and store the file on the mid server itself)
  • Format: XML
  • Resource: incident
  • Query Parameters: sysparm_query=active%3D1%5Epriority%3D1 (Notice how I need to URL Encode the query since it contains “=” signs.)
  • Output File: c:\MIDServer\agent2\activeP1incidents.xml

Download the Activity Update Set

ServiceNow Export Activity for Orchestration via PowerShell