Look Up Records action
Summarize
Summary of Look Up Records action
The Look Up Records action in ServiceNow’s Workflow Studio enables you to retrieve multiple records from any table based on specific conditions. It is designed for users withflowdesigneroradminroles to incorporate efficient record retrieval into flows, streamlining data processing and automation.
Show less
Key Features
- Table Input: Specify the table name containing the records to look up.
- Conditions: Define field names and values to filter records. You can also use inline scripts with GlideRecord and GlideQueryCondition classes for advanced queries.
- Order By: Select a field to sort the results, with options for ascending or descending order.
- Max Results: Limit the number of records returned to improve flow performance (recommended 1000 or fewer).
- Outputs: Provides a list of record Sys IDs, the table name, and the count of records found, which can be used as inputs in subsequent flow actions.
Practical Guidance for Use
- Use For Each Logic: To process multiple records returned, incorporate For Each flow logic to iterate through the list efficiently.
- Optimize Performance: Set the Max Results parameter thoughtfully and apply specific conditions to reduce system resource usage and enhance performance.
- Example Use Case: When an emergency change request is opened in the Network category, you can use this action to look up configuration items assigned to the requester by querying the Configuration Item [cmdbci] table, sorting results alphabetically by Name, and retrieving relevant records with their Sys IDs.
What to Expect
By using the Look Up Records action, ServiceNow customers can efficiently retrieve targeted sets of records based on defined criteria, enabling automation workflows to make informed decisions or perform batch operations on relevant data sets. The action’s outputs provide easy integration points for subsequent flow steps, facilitating scalable and maintainable automation processes.
Look up multiple records on any table using defined conditions.
Roles and availability
Available as a Workflow Studio ServiceNow core action. Users with the flow_designer or admin role can add an action to a flow and define configuration details.
Inputs
Provide a value for each input that your flow needs. To add dynamic values, you can also drag pills from the Data panel or select them from the pill picker.
- Table
- Data type: Table Name
Table name containing the records you want to look up.
- Conditions
- Data type: Conditions
Field names and field values that you want to use to search for records. To use an inline script to specify conditions, consider using the GlideRecord and GlideQueryCondition classes to build your query. See GlideRecord - Global and GlideQueryCondition - Global.
- Order by
- Data type: Field Name
Field you want to use to sort results.
- Sort Type
- Data type: Choice
Option to sort alphabetically in ascending or descending order.
- Max Results
- Data type: Integer
The maximum number of record results the action can return.
Outputs
These outputs appear in the Data panel. You can use them as inputs elsewhere in your flow.
- Records
- Data type: Records
List of record Sys IDs found based on the lookup criteria that you provided. For more information, see Records.[Table] data type.
- Table
- Data type: Table Name
Table that contains the list of records.
- Count
- Data type: Integer
Number of records that the action returned.
General guidelines
Use these general guidelines when working with the Look Up Records action.
- Process records with For Each flow logic
- Use For Each flow logic to iterate through a list of records. For more information about using For Each flow logic, see For Each flow logic.
- Set Max Results to improve performance
- Set the Max Results input to 1000 records or lower to improve the performance of your flow. The more records that the system has to look up, the more system resources it takes to identify and process them.
- Use conditions to filter records
- Use conditions to limit the number of records the action returns. The more specific conditions that you can provide, the better performance your flow has.
Look up configuration items assigned to a change request user
In this example, the flow starts when an emergency change request is opened in the Network category. The Look Up Records action uses the Configuration Item [cmdb_ci] table as the Table input. The Conditions input looks for configuration items assigned to the requester of the change request. The Order by input uses the Name field to perform an ascending alphabetical type sort.
In the execution details, the Count output shows three configuration items that are assigned to the requester of the change request. The Records output shows the configuration items by name in the execution details page, but the data pill contains a series of Sys ID values. The Table output is the Configuration Item [cmdb_ci] table.