Retrieve: Query Task
The Workflow Query task allows you to fetch records in near-real time for any object by Id. The Query Task can also bring records from auto-linked objects under the base object. Filter conditions are provided for subsequent objects linked under the base object.
When you create a Query task, you should select a data object and provide its Id to query data against. Select the data fields for which you want to return results, and specify the conditions for filtering the data.
Difference between the Query task and the Object Query task
The object query and the new task can be used for synchronous data retrieval. Compared to the existing Object Query task, the new task supports a wider range of objects, including custom objects, and returns all objects associated with the selected source object. With the new Query task, you do not have to perform multiple object queries to get associated object data.
The maximum number of records that can be returned for the new Query task is 200 records for each selected associated object. This limit applies to the base object and any subsequent objects linked under the base object.
Task settings
- Task Name - Enter the query task name.
- Base Object - Click the dropdown to select a base object for the query. Base Object enables you to select the object Field, Conditions, and Basic. For more information, see the Query tab, Basic tab, Fields tab, and Conditions tab.
You can only select the objects available in the Base Object drop-down list.
- Id - Enter a tag for the base object ID, such as Account ID.
Query tab
Click the checkbox under the Query tab to select the query for the base object. Based on the selected queries, you can configure the fields and conditions for the base object.
Basic tab
- Payload Placement - Payload Alternative Placement by default, the data payload for a query task is placed under the data object selected for the query. To avoid conflicts with concurrent query tasks that save multiple copies of data to the same object, you can specify an alternative placement for this query task. For example, if you query for the balance data in the Account object, the retrieved data will be placed under Account by default and can be referenced with "Account.Balance" in subsequent tasks. If you specify "Account_0" as the alternative payload placement, the retrieved data are placed under Account_0 and can be referenced with "Account_0.Balance".
- Search Tags - Enter the liquid tags used for searching in the logs.
- Strict Variables - Click the Strict Variables toggle icon to verify the Liquid expression specified in this task.
- Skip Validation - Click the Skip Validation toggle icon to skip the basic task validation on the task setting UI and allow the Workflow task to be saved.
If you wish the Workflow to stop when no data is returned in this query task, select Stop subsequent tasks if query returns no records.
Fields tab
- Object - Select the data object to query for data from. You can click the Show selected toggle icon to view only the selected objects. The query returns at most 200 records of each selected associated object.
- Fields - Click a data object from the left panel to display all available data fields in that object.
Conditions tab
Select a query under the Query tab. Under the Conditions tab, the dropdown lists will help you enter object fields and Workflow data fields in your query.
Not all fields are currently available for conditions. You can use a downstream task to do any further filtering.