Query Data reads records from a data list, document library, form report, or data report. Use criteria to find one or more records and map the fields you need to workflow variables.
When to Use the Query Data Action?
In a purchase approval workflow, match the supplier ID in the request to a supplier record. Save the supplier name and approver to workflow variables so a later step can assign the approval.
You can also retrieve an email subject and body from a template list, or map several fields from one record in a single query.
How to Use the Query Data Action?
To use the Query Data action, you can follow these steps:
From the workflow designer, find the "Query Data" action from the left actions panel.
Click and drag this action to the designer.
Click the settings button under this action to open the properties settings window.
In the properties settings window, you need to configure the following settings:
Action name: Set the display name of this action.
Description: Add a short description of this action.
Application: From the dropdown list, select the application which the data source come from. By default, the current application is selected.
Data source: Select the data source from the dropdown list. The data source can be a data list, a document library, a form report, or a data report.
Data filter: Click the "Condition" button to open the condition settings window.
Click the "Add Condition" button to add new condition to filter data. The first dropdown list shows all the fields of the selected data source. The second dropdown list includes the condition options. For the third column, click the editor icon to open the expression editor and choose the value from workflow variables, instance context etc. You can add multiple conditions to filter your data.
Primary Order: Choose one field as the primary field to sort by the query data.
Secondary Order: Choose one field as the secondary field to sort by the query data.
Query result group: Choose to query a Single item or Multiple items:
Single Item Retrieval: Fetch a single item and extract specific field values, storing them in workflow variables based on field types. This empowers you to build tailored workflows that react dynamically to data changes.
Multiple Item Retrieval: When you need to gather multiple items, the "Query Data" action allows you to collect them in a sub-list related workflow variable. This introduces a whole new level of process flexibility.
If you choose "Single item", then you need to select the fields which you want to use in this workflow.
Click the "Select fields" button to open the pop-up window.
Click the checkbox to select the fields from the selected data source. Once a field is checked, then choose a variable from the dropdown list of the "Associated variable" column.
This dropdown list will only list the existing variables with the same data type of the selected field. You can check to select multiple fields, and add the associated variables for each field.
Tip:
When the selected data source is a Document Library, the Upload File field can also be selected during field mapping.
Click "OK" button to save the settings and close this pop-up window.
If you choose "Multiple items", then you need to choose a List type of variable to save the returned items.
Click the "Select fields" button to open the pop-up window,
From Associated list, choose an existing List variable.
Select the source fields you need. For each field, choose its destination from the Associated variable column.
Click OK to save the mapping.
Under Multiple items, you can save the number of results to a variable and set the page number and page size. The default page size is 100, with a maximum of 1,000.
Check the results with test records
Test cases with one match, multiple matches, and no match. Check the sort order, mapped values, and any later workflow steps that read them. If a query supplies the approver, decide how the workflow should handle an empty result before using it in production.




