Chapter 23. Connecting to ServiceNow

An integration can retrieve records from a ServiceNow table or add records to a ServiceNow import set, which ServiceNow uses to update a table. In an integration, to connect to ServiceNow, create a ServiceNow connection and then add that connection to an integration. For details, see:

23.1. Creating a ServiceNow connection

In an integration, to connect to your company’s ServiceNow instance, you must create a ServiceNow connection.

Prerequisites

  • A ServiceNow administrator at your site must have created a ServiceNow account for you.
  • You must know the URL for your ServiceNow instance and your ServiceNow user name and password.
  • If the ServiceNow administrator also created a ServiceNow client ID and client secret for you, you must know these values.

Procedure

  1. In Fuse Online, in the left panel, click Connections to display any available connections.
  2. In the upper right, click Create Connection to display Fuse Online connectors.
  3. Click the ServiceNow connector.
  4. Configure this ServiceNow connection:

    1. In the Instance Name field, enter the name of the ServiceNow instance that you want to obtain records from or copy records to. For example, if the URL for your ServiceNow instance is https://abc12345.service-now.com, the instance name is abc12345.
    2. In the User Name field, enter your ServiceNow user name.
    3. In the User Password field, enter your ServiceNow password.
    4. Optionally, in the Client ID field, enter your client ID if you received one from your ServiceNow administrator.
    5. Optionally, in the Client Secret field, enter your client secret if you received one from your ServiceNow administrator.
    6. Click Validate. Fuse Online immediately tries to validate the connection and displays a message that indicates whether validation is successful. If validation fails, update the configuration details as needed and try again.
    7. When validation is successful, click Next.
  5. In the Name field, enter a name that helps you distinguish this connection from other connections. For example, enter ServiceNow Con 1.
  6. In the Description field, optionally enter any information that is helpful to know about this connection. For example, enter ServiceNow connection that uses administrative credentials.
  7. Click Save to see that the connection you created is now available. If you entered the example name, you would see that ServiceNow Con 1 appears as a connection that you can choose to add to an integration.

23.2. Obtaining records from ServiceNow to trigger integration execution

To trigger execution of an integration upon receiving records from ServiceNow, add a ServiceNow connection to a simple integration as its start connection.

Prerequisites

  • You created a ServiceNow connection.
  • You know the name of the table that you want to retrieve records from.
  • You should have already defined a ServiceNow query that obtains only the records that you want. You can find information about ServiceNow queries here: ServiceNow encoded queries.

Procedure

  1. In the Fuse Online panel on the left, click Integrations.
  2. Click Create Integration.
  3. On the Choose a connection page, click the ServiceNow connection that you want to use to start the integration.
  4. On the Choose an action page, select Retrieve Record to obtain records from a ServiceNow table that you select.
  5. Configure the Retrieve Record action:

    1. Click in the Table name field and select the table that you want to obtain records from.
    2. In the Query to filter the result set field, enter a ServiceNow query. For example, consider the state=1^impact=2 query on a table that keeps records about incidents. This query returns records for new incidents (state=1) that have a medium impact (impact=2). If you do not enter a query and the records in the table do not change, the connection obtains the same records every time.
    3. In the Limit of elements per page field, enter the maximum number of records that you want the connection to obtain. In this release, you must enter a value, the recommendation is to enter 1000 or less, and pagination is not supported.
    4. In the Period field, indicate how often you want to obtain records. The default is every minute. In other words, by default, Fuse Online executes this integration every 60 seconds.
    5. Click Next.

Results

Fuse Online generates a JSON schema that defines the structure of the obtained records. This enables you to add a data mapping step before the next connection in the integration if data mapping is needed.

Fuse Online prompts you to choose a finish connection.

23.3. Creating an import set in ServiceNow

In a Fuse Online integration, a ServiceNow connection cannot directly update a ServiceNow table. To update ServiceNow data in an integration, a prerequisite is an import set that stages updates for a ServiceNow table.

Often, the easiest way to create an import set is for a ServiceNow administrator to create a ServiceNow inbound web service. This implicitly creates a ServiceNow import set. The import set is based on the ServiceNow target table that the administrator selects when creating the web service. A ServiceNow connection updates this import set, and ServiceNow uses the import set to update the corresponding ServiceNow table.

Prerequisites

You must have ServiceNow administrative privileges.

Procedure in ServiceNow

  1. In ServiceNow, search for web services.
  2. In the results, under System Web Services > Inbound, click Create New.
  3. In the Create Web Service page:

    1. In the Label field, specify the display name for the web service. The web service’s import set will also have this name.
    2. In the Target table field, select the ServiceNow table that this service updates.
    3. Select Copy fields from target table. This creates an import set that has the same schema as the target table. The import set is a staging area for updating the target table.
    4. Select Create transform map. This map enables ServiceNow to copy and transform data from the import set to the target table.
  4. Click Create.
  5. In the next display, under Related Links, click Auto Map Matching Fields to display a list of fields in the target table that you selected.
  6. Select one target table field to be the correlation (or coalesce) field.

    When the value of the correlation field in a record in the import set matches the value of a correlation field in the target table, ServiceNow updates that record in the target table rather than creating a new record.

  7. Select Coalesce to identify the field that you just selected as the correlation field. Without a correlation field, ServiceNow adds each record in the import set to the target table.
  8. Click Update.
  9. Confirm that the transform map was created:

    1. In ServiceNow, search for transform map.
    2. Under System Import Sets, click Transform Maps to display a list of transform maps.
    3. In this list, confirm that there is a transform map whose name is the value that you specified for the label of the web service that you created.

23.4. Copying records to ServiceNow during or to finish an integration

You can copy records to ServiceNow in the middle of a flow or to finish a simple integration. To do this, add a ServiceNow connection to the middle of a flow or as a simple integration’s finish connection.

Prerequisites

  • You created a ServiceNow connection.
  • You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a finish connection.
  • You know the name of the ServiceNow import set that you want to add records to. Your ServiceNow administrator can help you identify the appropriate import set. If the import set does not exist, see Creating an import set in ServiceNow.
  • The ServiceNow import set is configured to handle the addition of records.

Procedure

  1. On the Add to Integration page, click the plus sign where you want to add the connection. Skip this step if Fuse Online is prompting you to choose the finish connection.
  2. Click the ServiceNow connection that you want to add to the integration.
  3. Select the Add Record action.
  4. Click in the Import Set field and select the import set that you want to add records to.
  5. Click Next.

Results

Fuse Online adds the connection to the flow.

Typically, a data mapper step is needed before this connection. In the integration visualization, Fuse Online displays Data Type Mismatch on the connection. In most integrations, you need to map a source field to the target field used as the correlation field in the ServiceNow table.

23.5. Example Salesforce to ServiceNow integrations

This example describes two simple integrations:

  • One integration obtains new cases from Salesforce and adds them as incidents to ServiceNow.
  • The other integration obtains updated cases from Salesforce and updates a corresponding incident in ServiceNow.

Prerequisites (in ServiceNow)

For both integrations, a prerequisite is for a ServiceNow administrator to create an inbound web service. This implicitly creates a ServiceNow import set, which is required for an integration to add data to ServiceNow. For this example:

  • The name of the web service is Cases from Salesforce.
  • The service’s target table is Incidents. This table contains the data to be updated.
  • The import set has the same schema as the Incidents table because of the selection of Copy fields from target table. The name of the import set is also Cases from Salesforce.
  • ServiceNow can copy and transform data from the Cases from Salesforce import set to the Incidents target table because of the selection of Create transform map.
  • In the import set, the correlation field is correlation_Id because of the selection of the correlation_Id field followed by selection of Coalesce.

Procedure overview (in Fuse Online)

In Fuse Online, you create the Salesforce and ServiceNow connections.

The two integrations are the same except for the action performed by the Salesforce connection, as noted in the following steps. To create the integrations, you would perform these steps twice, that is, once to create each integration:

  1. Add the Salesforce connection as the start connection.

    • To create the integration that obtains new cases, select the On create action.
    • To create the integration that obtains updated cases, select the On update action.
  2. Select the Case object for the action to operate on. This Salesforce connection returns new Case objects or updated Case objects according to the chosen action.
  3. Add the ServiceNow connection as the finish connection.
  4. Select the Create Record action, and then select Cases from Salesforce as the import set that the integration updates.

    This ServiceNow connection adds new or updated Salesforce cases to the Cases from Salesforce import set.

  5. Add a data mapper step that maps:

    • Salesforce case id to the ServiceNow import set’s correlation_Id
    • Salesforce subject to the ServiceNow short_description
    • Salesforce description to the ServiceNow description
  6. Give the integration a name and then publish it.

    • For the integration that obtains new cases, use On SF Create Case.
    • For the integration that obtains updated cases, On SF Update Case.

Confirm that the integrations work

When both integrations are running, you can confirm that the integrations work:

  1. In Salesforce, create a case.
  2. In Fuse Online, view the summary for the On SF Create Case integration. Click its Activity tab to see that Fuse Online executed the integration once.
  3. In ServiceNow, view the Incidents table. You should see a new incident that has the subject and description that you specified in Salesforce.
  4. Back in Salesforce, update the case that you just created by changing its subject.
  5. In Fuse Online, view the summary for the On SF Update Case integration. Click its Activity tab to see that Fuse Online executed the integration once.
  6. In ServiceNow, view the Incidents table and expand the entry for the incident that was previously new. You should see that this incident has an updated short_description value. ServiceNow checks the import set entry for the value of its correlation_Id. If this value already exists in the Incidents table, ServiceNow updates the incident that has that value.