Filtering record set data within Pageflex


Release 2.10 introduced a powerful new way of processing dynamic data for consumption in Pageflex templates. You may now apply filters to your recordselect variables, very similar to the way a database query operates. Below is a list of potential filtering options made available through this feature:

  • Limit the records made available to a recordselect variable by filtering results based on another variable established within a Pageflex variable XML
  • Filter records based on default values built into the Pageflex variable XML file
  • Assign multiple filters using the “AND” qualifier, where your filter should apply to multiple data sources or variables

Example use case scenario

Let’s say we’ve built an asset library of images that we want to incorporate into the design workflow. This asset library contains several hundred assets, each pertaining to a brand name. We don’t want the customer to have to scroll through every possible asset just to find the one that matches their specific branding. To resolve this, we’ll place a filter on the recordselect variable that will only pull the assets that are applicable to the brand our customer needs.

Before we apply this filter, let’s take a look at our asset library record to understand what will be used for filtering.

In our example, our asset record has four fields:

Brand – this will be the field we use to filter our results
AssetName – we will use this as the display value for our dropdown selector
Thumbnail – this will be used for our low-res image
File – this column contains the hi-res file that will ultimately be used in the production output file


Example of image assets loaded into records

Before we apply our filter, let’s look at the possible attribute values for recordselect that we will be using for this example:

Attributes for recordselect variables:

  1. recordType: Code of the record type to query.
  2. displayField: Name of the field to use for display values.
  3. storeField (new): Name of the field to use for stored values. Optional; if not provided, default to record ID. Note: Select distinct record values based on this field value.
  4. defaultDisplay (new): Default display (as opposed to stored) value for the variable. Note that this value will only be used if it is available in the dropdown. If a required option is also specified for the variable, then this value will be autoselected at page load.
  5. filter (new): Filter clause, with support for:
  • [field] IN $Defaults
  • [field] = '[value]'
  • [field] = $[variable]
  • Multiple clauses delimited by AND

Sample XML code for filtering

The sample XML below demonstrates how to create a recordselect variable that pulls from our Assets record and applies a filter on the Brand column:

        <variable order="2" name="Image1" attributes="recordType:Assets,displayField:Brand,storeField:File,defaultDisplay:LITE,filter:Brand = 'LITE'" type="recordselect" caption="Brand 1 (required)" required="Brand 1 is required"></variable>
    <default name="Package">
        <option value="LITE" >LITE</option>
        <option value="MGD" >MGD</option>
        <option value="Coors Light" >Coors Light</option>
        <option value="Coors Banquet" >Coors Banquet</option>
    <default name="Image1">
        <option value="LITE" >LITE</option>

In the example above, you'll note the following configuration for the attributes section of our XML variables:

This tells the design page to pull data from the Assets record.

The selector that is created will use the Brand column as the display value.

This sets the value of the selector to the File column in our Assets record when an item is selected. If you do not specify a storeField value, the selector will automatically default the value to the ID associated with the selected record.

This will set the default value of the selector to 'LITE'. This is an optional field.

filter:Brand = 'LITE'
The filter directive is telling the code to only pull assets where the Brand column = LITE. You may reference other fields for this value as well. As an example applying a filter like this: filter:Brand = $var_Brand, it would pull the value from another field set up in the XML template. Additionally, you can request that the selector filter based on the defaults section of your XML. If you have a defaults section set up with the same name as the variable executing the call, you could reference the brand value like this: filter:Brand in $Defaults. This would include ANY brand found in the defaults section where the text matches the assets available in brand choices.