Limit Records with a Subquery Condition¶
The Result of Subquery condition creates a condition that simulates subconditions in SQL or SOQL.
For example, users may need to see all contacts from client accounts in healthcare industries. This would require a SQL/SOQL statement similar to the following:
SELECT Id, Name
FROM Contact
WHERE AccountId IN ( SELECT ID FROM Account WHERE Industry = 'Education' )
Here’s how to do this declaratively.
Using a Subquery Condition¶
Assumptions¶
Note
This tutorial assumes you have a Skuid page with a functioning model on an object that keeps track of contacts. The page includes a Table component attached to that model.
Create the condition [[]]¶
- In the Elements pane, click the Models tab.
- Click the model name.
- Below the model name, click Conditions:
- Click Add to create a new model condition.
- Click Save.
Configure the condition [[]]¶
Click the newly created condition, then edit:
- Field: AccountId
- Operator: =
- Value:
- Content: Result of a subquery
- Join object: Account
- Join field: AccountId
- State: Filterable default off.
Add a sub-condition [[]]¶
Click the model condition created in the previous section.
Click
Add a Sub-Condition to create a new sub-condition to the parent condition and edit the sub-condition:- Field: Industry
- Operator: =
- Value:
- Content: Single specified value
- Value: Healthcare
- Click Save then Preview.
The end user’s experience¶
When the page is loaded, only contacts from accounts in the healthcare industry are displayed.
Want to take it to the next level? Make the subquery condition a toggle filter on the page, so end users can turn the condition on and off.