Displaying Data from Related Objects Using Nested Data Repeaters
You can retrieve data from any child object of a parent object using a data repeater that contains another data repeater, data table, or data function.
Required Editions
| Available in: Salesforce Classic |
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition |
| User Permissions Needed | |
|---|---|
| To build, edit, and manage Site.com sites: | Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level |
| To edit the guest user profile: | Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level AND Manage Profiles and Permission Sets AND Customize Application |
The outer or parent data repeater connects to an object, such as Accounts. In turn, the inner data repeater, data table, or data function automatically lets you connect to any child objects, such as Contacts. This is also known as a nested data repeater. For example, if a data repeater is connected to Accounts, you can add a nested data function to it that's connected to Contacts to return the number of contacts associated with each account.
To create a nested data repeater:
- Add a data repeater to the page.
- Drag another Data Repeater, Data Table, or Data Function from the Page Elements pane onto the data repeater.
-
Select the related Salesforce object that you want to connect to.
Note You can also retrieve data from unrelated objects. However, as this can adversely affect the performance of your site, we recommend retrieving data from related objects only. -
Optionally, in Filters, select criteria to filter your data set. If you don't
select any criteria, all the data from the item is returned.
- Select the field to which the filter criteria apply. The Field drop-down list displays the object's fields, followed by the fields of all parent objects, which use the format parent_object_name.field_name.
- Select the operator to control how results are filtered. For example, select Equals to return an exact match.
- Select the source of the filter value. For example, to specify an explicit value, select Fixed value, or to use the values passed to the page via a query string, select URL query string.
- Set the value of the filter. If you're using a query string, you can also specify what should happen if the query string is missing.
- Add additional filter criteria as required to narrow your results further. Each filter item is combined with an AND operator.
Note If you're using a fixed value to filter the results, you can view the returned records in the Connection Preview section. To refresh the list of records, click Reload Preview. - In Sorting, you can specify whether to sort the results by one or more fields in ascending or descending order. For example, if you're working with an object that contains user data, you could sort your results by gender first and then by name.
- In Limits, you can limit the number of returned results. For example, if you're only interested in the top five results, enter 5 in the Limit results to field.
- If you're adding pagination, specify the number of results to display per page in the Results per page field.
-
If you're working with a data table, click Next and add
fields to the table by double-clicking a field, or selecting it and clicking
.
- Click Save.
You can either add data elements or custom code to the parent repeater to display its fields. Similarly, if you've nested a data repeater inside the parent data repeater, add data elements or custom code to the nested data repeater to display the child object's fields.
