> For the complete documentation index, see [llms.txt](https://docs.adaptiva.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adaptiva.com/platform/user-guide/integrate-servicenow.md).

# Integrate ServiceNow

Integrate the Adaptiva OneSite Platform with ServiceNow.

The Adaptiva OneSite platform can connect to your ServiceNow instance and synchronize asset data and business logic. Using ServiceNow's Encoded Query Strings syntax, you can create Adaptiva groups that can be used to apply policy to devices.

## Configure OAuth settings in ServiceNow

Adaptiva uses OAuth inbound authentication to securely access ServiceNow APIs. You will need to create a new inbound grant as well as a user account to provide access to the Configuration Management Database (CMDB) in ServiceNow.

### Create an inbound integration record

1. In ServiceNow, navigate to **System OAuth > Inbound Integrations**. You can search for settings by clicking All and typing OAuth.

![Inbound Integrations](https://1238239958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzBcNZqjCKqgdpA83eD4o%2Fuploads%2Fgit-blob-01dd79e9c9f63ef360bbb3b7a9e116836b569356%2Fservicenow-integrations.png?alt=media)

1. Click **New integration**.

   The registered applications should use the *Resource Owner Password Credentials* inbound grant type. This will allow the OneSite platform to directly use a service account user's credentials to access the ServiceNow application.

   ![Grant type](https://1238239958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzBcNZqjCKqgdpA83eD4o%2Fuploads%2Fgit-blob-d6009bfe26ff152083fd8e5d039874145a2e8f35%2Fservicenow-granttype.png?alt=media)

   * Enter a **Name** and **Provider name**.
   * Under Auth scope, click **Create auth scope**.
   * Name the auth scope and click **Save**.
   * Select your auth scope from the drop-down.
   * In the **Limit authorization to the following API's** field select **Table API**.

     ![Auth Scope](https://1238239958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzBcNZqjCKqgdpA83eD4o%2Fuploads%2Fgit-blob-5ba4913a0fabeb8a43d60e0d57f97971b50137cb%2Fservicenow-authscope.png?alt=media)

     <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>If you have an organizational requirement to enforce token restrictions, please reach out to our <a href="mailto:ticket@adaptiva.com">Support Team</a> for assistance.</p></div>
2. Record the **Client ID** and **Client secret** for use in the Adaptiva Admin Portal.
3. Click **Save**.

### Create an API user

1. In ServiceNow, navigate to **System Security > Users and Groups > Users**.
2. Click **New**. We recommend creating a new user just this purpose.
3. Enter a **User ID** and any additional details you require.
4. From Identity type, select **Machine**.
5. Record the **User ID** for use in the Adaptiva Admin Portal.
6. Click **Submit**.
7. Click the new user to open it's properties page.
8. Under Roles, configure the permissions for the user to:
   * Role: **cmdb\_read**

     ![ServiceNow User Roles](https://1238239958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzBcNZqjCKqgdpA83eD4o%2Fuploads%2Fgit-blob-8abc48a6825cff37653d778b8a53046a09f507fd%2Fservicenow-user.png?alt=media)

     <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>The script writer permission, <strong>snc_required_script_writer_permission</strong>, is inherited from <strong>cmdb_read</strong> and will appear in the user settings.</p></div>
9. Click **Set Password**.
10. In the Set Password dialog, click **Generate**.
11. Click the copy button and record the **Password** for use in the Adaptiva Admin Portal.
12. Click **Save Password** and then click **Close**.
13. Configure any additional user account settings and click **Update**.
14. You should now have the following details recorded form your ServiceNow instance:
    * Instance name
    * Username
    * Password
    * Client ID
    * Client secret

## Configure integration settings in OneSite Platform

1. Log in to the Adaptiva Admin Portal with Super Admin credentials.
2. In the left-hand navigation, click **Integrations > ServiceNow**.

   ![ServiceNow integration](https://1238239958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzBcNZqjCKqgdpA83eD4o%2Fuploads%2Fgit-blob-950c909e2322cc84b05cafbc140ec4c15181b24e%2Fadaptiva-integration.png?alt=media)

   You can create one or more connections to ServiceNow instances.
3. Click **New**.
4. Under General Settings, enter a descriptive name for the instance that can identify it from any others.
5. Under ServiceNow Instance Settings, enter the values recorded from your ServiceNow instance:
   * **Instance Name**
   * **Username**
   * **Password**
   * **Client ID**
   * **Client Secret**
6. Click **Save**.
7. Click **More > Test Settings** to test the connection to ensure the details entered are correct.

## Example: Create Group from ServiceNow query

You can create queries using ServiceNow's Encoded Query Strings syntax (see [ServiceNow filters and queries](https://www.servicenow.com/docs/r/platform-user-interface/c_EncodedQueryStrings.html)) to scope a group to a specific set of devices synchronized from the ServiceNow CMDB. In this example, you will create a group for all devices in the Operations department based on a simple query.

1. On the left-hand navigation, expand **Platform Features** and click **Assets > Groups**.
2. Click **New** and name the group **Operations Devices**.
3. Under **Group Scopes**, select **ServiceNowCMDB**.
4. In the Select Instance drop-down, select your ServiceNow instance.
5. In the query editor, enter **Department.name=operations**.
6. Click **Save**.
7. Under **Group Scopes**, click **Show Members** and then click **Evaluate Membership**.
8. The query will return the devices in the Operations department queried from the ServiceNow CMDB.

You can use any ServiceNow attribute and query it using ServiceNow's Encoded Query Strings syntax. This allows you to use ServiceNow to manage your device inventory, and Adaptiva OneSite will seamlessly integrate, synchronize, and manage devices using that data.
