Limit Records with a Subquery Condition

The Result of Subquery condition creates a condition that simulates subqueries 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 [[]]

  1. In the Elements pane, click the Models tab.
  2. Click the model name.
  3. Below the model name, click Conditions:
  4. Click fa-plus-circle Add to create a new model condition.
  5. Click Save.

Configure the condition [[]]

Click the newly created condition, then edit:

  1. Field: AccountId
  2. Operator: =
  3. Value:
    • Content: Result of a Subquery
    • Join Object: Account
    • Join Field: AccountId
  4. State: Filterable Default Off.

Add a sub-condition [[]]

  1. Click the model condition created in the previous section.

  2. Click fa-plus-circle Add a Sub-Condition to create a new subcontion to the parent condition and edit the sub-condition:

    • Field: Industry
    • Operator: =
    • Value:
      • Content: Single specified value
      • Value: Healthcare
    1. 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.