Utilities transform functions
Summarize
Summary of Utilities transform functions
Utilities transform functions in ServiceNow allow you to manipulate and extract data from Arrays, Name-Value Pairs, Strings, Integers, or Choice data pills. These functions help you return complex objects, specific values, or perform logical checks on input data types. Applying the correct input data pill type is essential, as improper types result in no transformation and simply return the original value.
Show less
Key Functions and Their Uses
- Get First Item from Array: Retrieves the first complex object from an input array.
- Get Item from Array: Returns the complex object at a specified zero-based index (Nth item) in an array.
- Get Item from Name/Values: Extracts a value associated with a given key from a map of Name-Value Pairs, with an option to specify a default if the key is absent. Note that the returned value may be a system value rather than a display value, important when mapping fields like priorities.
- Get Last Item from Array: Retrieves the last complex object from an input array.
- Logical Checks (Is Blank, Is False, Is Not Blank, Is Null, Is True): Evaluate input data pills of various types to return boolean results indicating blankness, truth, falsity, or nullity. These do not support reference inputs.
- Key Value Map: Maps a key (String or Integer) to a corresponding value, returning a default if no match is found. Useful for transforming codes into descriptive strings.
- Sort: Sorts arrays (String, Integer, Boolean, or Datetime) in ascending or descending order. Note that sorting for string arrays is case-sensitive.
- Unique: Removes duplicate elements from arrays, returning an array with unique entries.
- Join: Concatenates array elements into a single string separated by a specified delimiter.
Practical Impact for ServiceNow Customers
These transform functions empower you to precisely manipulate data within flows and integrations, enabling efficient data extraction, transformation, and logical evaluation. For example, you can extract specific elements from arrays returned by REST calls, map priority codes to descriptive strings for logging, or clean arrays by removing duplicates before processing. Logical functions help you conditionally branch flows based on data state.
Understanding the expected input types and behavior of these functions ensures accurate data transformations and reduces runtime errors. Using these utilities effectively will streamline your automation, improve data handling consistency, and enhance integration reliability within your ServiceNow environment.
Use utilities transform functions to return a Complex Object from an Array, or a value associated with a specific key.
Utilities transform functions require an Array, Name-Value Pair, String, Integer, or Choice input data pill. Make sure to use the correct input data pill type when applying utilities transform functions. If a utility transform function is applied to an improper data type, the data is not transformed at runtime and the input value is returned instead. For more information on confirming your flow runtime values, see Test a flow.
Get First Item from Array
Returns the first item from the input array as a complex object.
| Input data pill | Output data pill |
|---|---|
| Array | Complex Object - First item found in the input array |
Get Item from Array
Returns a Complex Object from the input Array. Enter a value for the Nth Item in the input Array that you want to return. The Nth Item represents the Array index, starting at 0.
| Input data pill | Parameters | Output data pill |
|---|---|---|
| Array | Nth Item - Enter the index of the target object in the input Array. The Array index starts at 0. | Complex Object |
Get Item from Name/Values
Returns a value that is associated with a matching key from a map of Name-Value Pairs.
| Input data pill | Parameters | Output data pill |
|---|---|---|
| Name-Value Pairs |
|
String associated with the matching key |
- Input:
"username":"abel.tuter" - Key:
username - Default:
example.username - Output:
abel.tuter
In this example, an action makes a REST call to a third-party system and GETs ticket data as a map of Name-Value Pairs. A Ticket ID is provided as an output for this action. The Get Item from Name/Values transform function
returns either the value that is associated with the ticket_id key or Ticket ID not found.
Get Last Item from Array
Returns the last item from the input array as a complex object.
| Input data pill | Output data pill |
|---|---|
| Array | Complex Object - Last item found in the input array |
Is Blank
| Input data pill | Output |
|---|---|
| Any | Returns true or false |
- Input: an integer data pill with
0 - Output:
true
Is False
Returns true when the input is false. A string is false when it is an empty string. An integer is false when it is zero. A Boolean input is false when it is false.
| Input data pill | Output data pill |
|---|---|
| Any | Returns true or false |
- Input: an integer data pill with
13 - Output:
false
Is Not Blank
| Input data pill | Output data pill |
|---|---|
| Any | Returns true or false |
- Input: an integer data pill with
13 - Output:
true
Is Null
Returns true when the input value is null. An input is null if it is not initialized, or if it is a null object or reference.
| Input data pill | Output |
|---|---|
| Any | Returns true or false |
- Input: an integer data pill with
725 - Output:
false
Is True
Returns true when the input is true. A string is true when it is not an empty string. An integer is true when it is anything but zero. A Boolean input is true when it is true.
| Input data pill | Output data pill |
|---|---|
| Any | Returns true or false |
- Input: an integer data pill with
13 - Output:
true
Key Value Map
Returns a value associated with a matching key, or a default value if there is not a match.
| Input data pill | Parameters | Output data pill |
|---|---|---|
| String or Integer |
|
String associated with the matching key |
Example usage:
In this example, a log action stores a record's priority as a message. In the Name-Values section, each priority is mapped to a corresponding string value. When the flow runs, the record's priority number is transformed to a string, and the string is logged to a message.
Sort
Sorts the specified array in ascending or descending order.
| Input data pill | Parameters | Output data pill |
|---|---|---|
| Array.String, Array.Integer, Array.Boolean, or Array.Datetime. - Unsorted array | Sort Order - Ascending or descending | Array - Sorted array |
- Input:
[7, 2, 3, 1, 7, 9] - Parameter: Ascending
- Output:
[1, 2, 3, 7, 7, 9]
Unique
| Input data pill | Output data pill |
|---|---|
| Array.String, Array.Integer, Array.Boolean, or Array.Datetime. | Array - After duplicated elements are removed |
- Input:
[7, 2, 3, 2, 7, 9] - Output:
[7, 2, 3, 9]
Join
Concatenates the individual elements of the specified array with the specified delimiter and returns the concatenated string.
| Input data pill | Parameters | Output data pill |
|---|---|---|
| Array.String, Array.Integer, Array.Boolean, or Array.Datetime. | Delimiter - Character that separates the individual elements after concatenation. | String - String after a delimiter is added. |
- Input:
[1, 2, 3] - Parameters:
< - Output:
1<2<3