LCS - Using Advanced Filter to Pass Collection with Children to Action for Gen PDF
This document describes how to use an ADVANCED FILTER to pass collection criteria to an action and generate a PDF to report on that collection AND ITS CHILDREN.
Start on your page
-
Add a data table to your page to list the rows of a model.
-
Add a non-model-based form ABOVE and OUTSIDE the data table; assigning a suitable action name.
-
Insert the Advanced Filter into that Form.
-
Update the Filter with the model named in the data table.
-
Update the Filter, adding a text-type action input variable (named ‘filter_query’ in this example).
-
Change the Box holding the ‘Add Filter Group’ to align on the right.
-
Delete the ‘Add Filter Group’ button from the Filter (groups won’t work in the Form’s action).
-
Change the Form’s ‘Send’ button to something like ‘Gen PDF’. (This button must remain inside the Form, but OUTSIDE the Filter.)
-
Set that button’s Toggle Visibility to hide it (to prevent it’s use before criteria are entered).
-
Add a data container for the model that will hold the PDF; position it AFTER and OUTSIDE the Form, BEFORE the data table. (See “Component Tree Structure” image shown below.)
-
Define an Open Page button within that data container to open an external page in a new tab and enter the URL of the PDF property; label the button something like ‘Open PDF’.
-
Add a condition around that Open Page button to only show it when the URL contains https (to prevent the user from clicking the button before a PDF exists)
-
Add an interaction to the ‘Apply Filter’ button to show the ‘Gen PDF’ button when clicked.
-
Verify that your component tree structure closely resembles the Component Tree Structure image shown below.
-
Compile the page.

In the Form’s action:

-
Add an Expression passing it the Form’s action input variable (filter_query) as ‘filter’; this example names the text result as ‘the_final_filter’.
Find the full Filter Query to copy and paste here: LCS - Using Advanced Filter to Pass Collection with Children to Action for Gen PDF Code and Expressions for Copy and Paste

-
(Optional) Use an Expression to get the current date time (for use in this example’s PDF file name). In this example, the Result was ‘dttm’ as Text.

new Date().toLocaleDateString("nl-NL", { month: '2-digit', day: '2-digit', year: 'numeric',
hour: '2-digit', minute: '2-digit' })
-
(Optional) Use an Expression to reformat the date time (for use in this example’s PDF file name). In this example, the Variable Key was ‘string’ and the Value was ‘dttm’; the Result was ‘dttm’ as Text.

"{{string}}".substr(6,4) + "-" + "{{string}}".substr(3,2) + "-" + "{{string}}".substr(0,2) + "_" + "{{string}}".substr(12,2) + "-" + "{{string}}".substr(15,2)
-
(Optional) Use an Expression to format the PDF’s file name. In this example, the two Variables are passed into the expression: Key ‘type’ with Value ‘Publicuser’ and Key ‘dttm’ with Value ‘dttm’; the Result was ‘file_name’ as Text.

"{{type}}" + "-Object_Report_" + "{{dttm}}" + ".pdf"
This is an example of the Result ‘file_name’: Publicuser-Object_Report_2025-07-21_11-54.pdf
-
Add a Data API Request step (from the Block Store)
-
-
- Set Model to the one named in the Filter.
- Set Type to ‘Collection’.
- Set Filter to ‘the_final_filter’ (the name given to the first Expression’s result).
- Set the Skip and Take values according to your needs.
- Populate Query Data with the GraphiQL names of all the properties to be used in the PDF.
- Set Output Type to ‘Results’.
- Set the Result name; set it as Type ‘Collection’.
-

-
Add a Generate PDF step (from the Block Store)
-
-
- Populate the HTML with your code.
- Add a variable:
- Set the Key as the model named in the Data API Request.
- Set the Value as the Result (collection) named in the Data API Request.
-

Note: Visual Studio Code is a free tool that’s good for coding/saving HTML.
This example’s HTML is included in the next section.
-
Update the appropriate model/row to store the PDF and its file name.
Here’s an example of the PDF output image:

Code the HTML for ‘Generate PDF’ in the tool of your choice, including in the body:
-
Reference models and properties by their GraphiQL names. (These are camel-case; the precise names are available in the Playground.)
-
{% for objectrec in object %} – where object is the name of the model that will be named in the Gen PDF step, and objectrec is how its properties are referenced within the HTML.
-
{% for photorec in objectrec.objectPhotos %} – where objectPhotos is the child model of the model that will be named in the Gen PDF step, and photorec is how its properties are referenced within the HTML.
-
{% endfor %} – positioned after all the child model’s properties have been used.
-
{% endfor %} - positioned after all the parent model’s properties have been used.
Find the full Generate PDF Code to copy and paste here: LCS - Using Advanced Filter to Pass Collection with Children to Action for Gen PDF Code and Expressions for Copy and Paste