activities
latest
false
UiPath logo, featuring letters U and I in white
Classic Integrations Activities
Last updated Nov 8, 2024

Quickstart - How to Use Search ServiceNow Records

Overview

The purpose of this guide is to walk you through several examples of how to query for data using the Search ServiceNow Records activity.

You can enter a query such as "name-value pairs=state=closed" which says to filter the list of objects (such as an Incident) where the state is closed. This is described on ServiceNow's documentation and you can test this out using the ServiceNow REST API explorer. Our activity takes the query that the user supplies and appends it to the relevant ServiceNow REST API call and then receives the results.

The problem for some customers is that it is not easy to understand how to create queries, how to test queries, or that the person is not technical to the extent that learning and using the ServiceNow REST API explorer is practical.

Guide

ServiceNow's documentation regarding building queries that can be used with their REST API is located in the Encoded query strings documentation. This is a useful resource if you want to learn how to build queries that can be used with the Search ServiceNow Records Activity.

Below are some query examples that can be used with the Incidents object:

Query

Description

sysparm_fields=number,sys_created_on,sys_created_by

Returns all records, but returns only the three columns specified (number, sys_created_on, and sys_created_by)

name-value pairs=state=closed

Return all records where state is closed.

sysparm_fields=number,sys_created_on,sys_created_by&sysparm_limit=1&name-value pair=state%3Dopen

Return only the three columns (number, sys_created_on, and sys_created_by) for each record, return only records where the state is Open, and limit the results to 1 record.

priority=2

Return all records where the priority is 2.

sysparm_query=active=true&state=closed

Return all records where the short description is like network

sysparm_query=short_descriptionLIKEnetwork

Return one record where the number is INC0010060 and only return three columns as part of the result (sys_id, number, short_description)

There are two other methods to create and obtain useful queries that can be used with this activity.

  1. Option A: Copy any query from the ServiceNow UI.
  2. Option B: Copying the query string from the browser.
Option A: Copy any query from the ServiceNow UI

You will need to prepend the text "sysparm_query=" to any query that results per the steps below.

Step 1

Go to an object, Incidents in this case.



Step 2

Clear out the filters and create a new filter. In our case we are looking for any Incidents whose number ends with the string "100".



Step 3

Copy the query suing the Copy Query menu item. It will look like numberENDSWITH100.



Step 4

Paste this into the Search ServiceNow Records activity. You can do this in the Test Query window as seen below, or in the query property of the activity.

Be sure to pre-pend sysparm_query= in front so that it looks like sysparm_query=numberENDSWITH100, else it will not work correctly.



Option B: Copying the querystring from the browser.

In this option you do not have to remember to do add anything as a pre-pending step. You can copy and paste the query string if you use the Open new Window option like below:

Step 1:

Create the filter you want to use as before in Option A.

  Step 2: Right-click and choose the Open new window menu option.



Step3: Copy the query string in toto (everything after the question mark "?"). Then paste it directly in the “Test Query” dialog of the Search ServiceNow Records activity as seen below.



  • Overview
  • Guide

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.