Repeatable SOQL Filters
Intro
Repeatable containers are containers that repeat for each record in a record set. Most often than not, this will be a child record of the contextual object
Usage
When a repeatable container is added on a template, you can set a custom SOQL filter to limit the number or type of records for the repeatable record set.
Validation
The application will validate the inputted SOQL Filter by performing an SOQL query on the contextual object with a limit of 0 records. Any errors that are identified in the SOQL Query will be returned as an error message against the SOQL filter input.
Note that if you are adding URL Params as filters in the SOQL, the app will validate the SOQL Filter entered with a placeholder value of an empty string.
Tips, Tricks and Gotchas
- You can request all records to be returned by using the filter
"Id != null"
- You can add
ORDER BY
declaration to sort records by your custom criteria - You can use
LIMIT
declaration, however, be mindful that by default we apply a hard limit of 50. If you apply your own limit statement, it will override the hard limit of 50 returned records
URL Params
You can pass filters to repeatable containers from the URL of the document using this syntax: {params.xxxxx}.
Example SOQL Query:
Name = '{params.name}'
With the above example, we are requesting that we filter the repeatable container based on the field "Name" with the merge variable {params.name}
.
Example Document Link
.../b3d__Document?templateId=XXXXXXXX&recordId=XXXXXXXX&name=James
When we load the document with the above URL, the parameter &name=James
will be auto-applied to all SOQL Queries (repeatable blocks) that implement a filter with {params.name}
Example
Custom SOQL Query: Name = '{params.name}'
Document URL: .../b3d__Document?templateId=XXXXXXXX&recordId=XXXXXXXX&name=James
Compiled Limiting Query: SELECT <fields> FROM <object> WHERE <otherfilters> AND Name = 'James'
Considerations
- We store custom SOQL filters in the object "SOQL Filter" and we retrieve records by the unique identifier. If an SOQL Filter record is deleted, it may break the template(s) that implement it.