Use the ServiceNow plugin’s Filter field
The following examples illustrate how to use the ServiceNow plugin Filter field:
Basic Filter field usage
The Filter field is used in the Collect Reporting Data, Get Record, and Update Record procedures. Valid Filter entries can either be:
-
JSON filters: These are simple JSON filters consisting of a ServiceNow table column actual name, and a value or label. For example,
{"assigned_to": "user123"}
, where:-
assigned_to
is the actual name of a table column display name. -
user123
is a username value.JSON-based filters cannot use complex filtering syntax.
-
-
ServiceNow query language filters: These can be either simple or complex filters consisting of ServiceNow table column actual names, values or labels, and optional operators. For example:
short_descriptionISEMPTY^ORdescriptionISEMPTY^priority=1
Where:
-
short_description
,description
, andpriority
are actual names of table columns display names. -
ISEMPTY
and1
are values and labels. -
^OR
and^
are operators.For complex filters, you must use ServiceNow operators. For more information, refer to Use ServiceNow operators in filters.
-
When using either filter type, always ensure you are using the actual name of the table column you want to filter for. For more information, refer to Find the actual names of columns in ServiceNow tables.
Find the actual names of columns in ServiceNow tables
To find the actual names of table columns in your ServiceNow tables:
-
In ServiceNow, navigate to
. -
In the Table Names list, find the table type you want to filter for, and select its name. The Column Names list opens.
-
In the Column Names list, find the column you need the name attribute for, and select its name. The Column Attributes list opens.
-
In the Column Attributes list, find the name attribute in this list, and to the right of it, is the actual name of the column.
You must always use actual names when constructing your simple or complex filters.
Use ServiceNow operators in filters
When writing complex filters using the ServiceNow query language, the Filters field supports using ServiceNow operators to construct complex queries. The following examples demonstrate basic usage:
-
To return only the results for incidents that are both
"critical": "1"
and"impact": "1"
usingand
:priority=1^impact=1
-
To return the results for incidents that are either
"critical": "1"
and"impact": "1"
usingor
:priority=1^ORimpact=1
-
To return the results for incidents that are
"critical": "1"
but not"impact": "1"
usingis not
:priority=1^impact!=1
For a complete list of ServiceNow operators and examples, refer to the Operators available for filters and queries. |
ServiceNow CloudBees CD application
The CloudBees CD application is installed in ServiceNow to facilitate an approval or rejection of a change request by a ServiceNow user to perform an action in CloudBees CD/RO (via a Rest API call) based on a business rule associated with a change_request
table. This integration calls a run procedure API and runs a job on the CloudBees CD/RO server. This job approves a specified stage’s exit gate and moves a pipeline to the next stage.
The following steps demonstrate how to use the CloudBees CD application and the ServiceNow plugin to provide bidirectional integration between CloudBees CD/RO and ServiceNow.
To configure bidirectional integration between CloudBees CD/RO and ServiceNow:
-
Install the CloudBees CD application available in the ServiceNow Store in your ServiceNow instance as an Admin user.
-
If you do not install the CloudBees CD application as an Admin user, it must have the following rights to function:
-
import_transformer
-
EFImportTableAdmin
-
-
-
Upon installation, the application creates a special user group named ServiceNowChangeApprovers with appropriate access rights in CloudBees CD/RO.
-
Activate the CloudBees CD application in ServiceNow.
-
In CloudBees CD/RO, use the Create Change Request procedure to create a change request as the first pipeline task.
-
Set the Correlation ID parameter as follows, where
%StageName%
is the name of the stage that contains your gate, and%GateName%
is your gate’s name./flowRuntime/$[/myPipelineRuntime/id]/stage/%StageName%/gate/POST/taskName/%GateName%
-
Set the Correlation Display parameter as follows:
ElectricFlow Pipeline Gate
-
-
Create a pipeline gate with an approval step for that pipeline.
-
Create a pipeline task that should be performed only if the pipeline gate has been approved.
-
Create a change request on the ServiceNow instance using the ServiceNow plugin in CloudBees CD/RO.
-
After the change request is approved or rejected on the ServiceNow side, ServiceNow sends a notification to the CloudBees CD/RO server where the ServiceNow plugin is installed.
-
The ServiceNow plugin uses an internal procedure to approve or reject the pipeline gate that is waiting on manual approval.
-
The pipeline continues if the pipeline gate is approved or is aborted if the pipeline gate is rejected.