ServiceNow v2

Provides integration with ServiceNow, a cloud platform for IT service management and other business workflows, where each organization runs its own instance and stores records such as incidents, changes, users and configuration items in tables.

Use this Node to read, create, update and delete records in any table that the Connection user can access, including custom u_ and scoped x_ tables. Templates are built from your instance's own tables and fields. For example, you can open or update incidents from events in other systems, synchronize users or configuration items, or export table data.

Revision History

0.0.0.3 - Initial release.

Connection

The Connection identifies your ServiceNow instance, stores the credentials for the selected AuthenticationType, and holds the table catalog that templates are built from. Only the Properties for the selected AuthenticationType are shown.

Property Type Description
InstanceUrl String The HTTPS address of your instance with no path, for example https://<instance>.service-now.com.
AuthenticationType Enum Basic (default), OAuthPasswordCredentials, OAuthClientCredentials or ApiKey.
Username String Basic and OAuthPasswordCredentials. The ServiceNow user name.
Password Masked Basic and OAuthPasswordCredentials. The ServiceNow user's password.
ClientId Masked OAuthPasswordCredentials and OAuthClientCredentials. The client ID from the ServiceNow OAuth Application Registry.
ClientSecret Masked OAuthPasswordCredentials and OAuthClientCredentials. The client secret from the ServiceNow OAuth Application Registry.
ApiKey Masked ApiKey. The REST API key token.
TimeoutSeconds Integer The timeout for each request in seconds, from 1 to 3600. The default is 60.

Each AuthenticationType keeps its own credential values, so switching between Basic and OAuthPasswordCredentials requires you to enter the user name and password for the selected type. For the OAuth types, the Node obtains and renews the access token itself.

Setup Notes

  1. In ServiceNow, create an integration user with only the roles your Workflows need. The user also needs read access to the sys_db_object and sys_dictionary tables, which hold the table catalog and field definitions. The admin role has this access, or you can grant another role read access to those two tables.
  2. For OAuthPasswordCredentials or OAuthClientCredentials, open System OAuth → Application Registry in ServiceNow, register an OAuth application, and copy its client ID and client secret.
  3. For OAuthClientCredentials, also set the glide.oauth.inbound.client.credential.grant_type.enabled system property to true and assign an OAuth Application User to the OAuth application. Requests run as that user.
  4. For ApiKey, the instance needs the API Key and HMAC Authentication plugin, an inbound API key authentication profile and a REST API access policy. Add both the Table API and the Batch API to the key's access policy. Reads use the Table API, and Create, Update and Delete use the Batch API. API keys run as the user on the key's record.
  5. Create a Connection for ServiceNow, enter InstanceUrl, select the AuthenticationType and enter its credentials.
  6. Test and save the Connection.
  7. Click Acquire Metadata to load your instance's table catalog. Templates are not available until it has run. Run it again after you add tables or change InstanceUrl.

This Node runs on the Cloud Cluster and on local Clusters. Use a local Cluster when your instance accepts requests only from your own network's IP addresses.

Methods

Use Get, List and Query to read records, and Create, Update and Delete to change them. Every Method lists one template per table in the acquired catalog, named <label> (<name>), for example Incident (incident). Selecting a template loads that table's fields, including fields inherited from parent tables such as task.

All field values are text, as ServiceNow returns them. Reference fields contain the referenced record's sys_id, and list fields contain comma-separated sys_id values. Set DisplayValue to true to return display values, such as a user's name, instead.

Fields takes a comma-separated list of field names with no spaces, for example sys_id,number,short_description. Leave it empty to return every field. A name that is not a field of the table fails the Step.

Get

Reads one record by its sys_id.

Parameter Type Description
Connection Connection The ServiceNow Connection.
TemplateKey String The key of the selected table template.
Options Object TableName, the table's internal name, such as incident. SysId, the 32-character sys_id of the record. Optional Fields and DisplayValue.
Return Type Description
Response Array The record as one row. When the record does not exist, or access controls hide it from the Connection user, no row is returned.

A TableName that is not in the acquired catalog fails the Step, so a mistyped table name is not mistaken for a missing record.

List

Reads every record of a table. Use Query to read only the records that match a condition.

Parameter Type Description
Connection Connection The ServiceNow Connection.
TemplateKey String The key of the selected table template.
Options Object TableName, the table's internal name. Optional Fields and DisplayValue.
Return Type Description
Response Array One row per record. An empty table returns zero rows.

Query

Reads the records that match a ServiceNow encoded query, for example active=true^ORDERBYDESCsys_created_on.

Parameter Type Description
Connection Connection The ServiceNow Connection.
TemplateKey String The key of the selected table template.
Options Object TableName, the table's internal name. Query, the encoded query, which is required. Optional Fields and DisplayValue.
Return Type Description
Response Array One row per matching record. A query that matches nothing returns zero rows.

A Query Step without a query fails with Query was not provided. Query needs an encoded query; use List to read the whole table.

ServiceNow ignores a condition whose field it does not recognize and returns the whole table instead. To prevent this, every field in Query must be a field of the table or one of its parent tables, and an unknown field fails the Step with a message naming it.

Create

Creates one record per item. Each item names its own table, so one Step can create records in several tables.

Parameter Type Description
Connection Connection The ServiceNow Connection.
TemplateKey String The key of the selected table template.
Options Object InputDisplayValue, true to treat the supplied field values as display values. DisplayValue, true to return display values.
Items Array One record per item: TableName and the fields to set. The template lists the table's writable fields.
Return Type Description
Response Array One row per item: the created record, including its new sys_id, and a Flowgear object with IsSuccess, Message and Request.

Update

Changes the supplied fields of one record per item. Fields you do not supply are not changed.

Parameter Type Description
Connection Connection The ServiceNow Connection.
TemplateKey String The key of the selected table template.
Options Object InputDisplayValue and DisplayValue, as for Create.
Items Array One record per item: TableName, the record's sys_id and the fields to change.
Return Type Description
Response Array One row per item: the updated record and a Flowgear object with IsSuccess, Message and Request.

Delete

Deletes one record per item.

Parameter Type Description
Connection Connection The ServiceNow Connection.
TemplateKey String The key of the selected table template.
Items Array One item per record to delete: TableName and the record's sys_id.
Return Type Description
Response Array One row per item with a Flowgear object containing IsSuccess, Message and Request.

Usage Notes

  • TableName and sys_id identify the record that each item writes to and are not written as fields. Flowgear.Request contains the whole item.
  • Fields with a null value are ignored and do not change the record.
  • Create, Update and Delete return one row per item, in input order. A failed item returns Flowgear.IsSuccess set to false and the reason in Flowgear.Message, for example HTTP 403 (Forbidden): .... If the first item fails, the Step fails.
  • Writes are not retried. When ServiceNow does not confirm a write, for example after a timeout or server error, the item's row says the outcome is unknown. Check the record in ServiceNow before you send that item again. After a timeout or server error, the remaining items are not sent and the Step fails.
  • When ServiceNow rejects the credentials, the Step fails with ServiceNow rejected the credentials. Check the AuthenticationType and its credential fields.
  • When ServiceNow throttles a request, the Node waits and retries it. If ServiceNow asks for a wait longer than 60 seconds, the request fails.
  • Records created or deleted during a long read can be skipped or repeated.
  • If a read fails because ServiceNow returned content that is not JSON, check that the instance is awake and that InstanceUrl is correct. Developer instances return a web page instead of data while they hibernate.

Known Issues

  • ServiceNow returns the same response for a missing record and a record hidden by access controls, so a Get that returns no row can mean either.
  • With ApiKey, any refusal of a write request reports that the Batch API is missing from the key's access policy. If the policy already includes the Batch API, check the roles of the key's user.
  • Templates use each table's own field definitions and do not apply dictionary overrides, so the mandatory or read-only flag shown for an inherited field can differ from the child table's setting.
  • A table with a field named TableName cannot be used with Create, Update or Delete, because its templates fail to load.
  • Returning both stored and display values in one row, attachments, aggregates, import sets and the OAuth authorization code flow are not supported.

See also