Objectif Lune joins Upland Software.Learn more >
Erik van den Heuvel
August 24th, 2021
Conditional print sections
A classic approach to dynamically switch messages is to enable or disable sections for printing. OL Connect’s Designer contains a basic condition wizard and a scripting API to toggle the visibility of print sections. In version 2021.1 we revamped the wizard. It allows conditions to validate against multiple data fields and it provides predefined operations based on the field type (e.g. check if a boolean field is true or is false).
The following example shows how to use the new wizard to skip or print sections for a university admission letter.
The templates contains the following sections:
The first section (Accepted) contains a message for students that are admitted to Green University, the second section is for less fortunate applicants. The third section contains a parent/guardian consent form for admitted students under 18 years of age.
The data model of the template contains information about the applicant and their admission status. The data (CSV) is read via a DataMapper configuration. This creates a data field for each column in the data file. It is also used to set the type of the admitted field to boolean (true/false) and created an integer field for the age of the applicant.
In order to toggle the visibility of the sections a condition needs to be set for each.
For the Accepted and Rejected sections we can setup a basic condition validating against a single data field (admitted).
To set up the condition for the Accepted section:
When the condition is met (i.e. the admitted field is true) the section will automatically be printed, otherwise it will be skipped i.e. not printed. In case the section is skipped, a red alert decorator is shown on the icon of the respective section in the Resources view.
Now one needs to setup a similar condition for the Rejected section. Repeat steps 1 and 2 but set the condition to is false. In this scenario the section will be printed then the value is false and for other scenarios it will be skipped.
Invoke the Preview mode and browse through the records. The decorators for the Accepted and Rejected sections will be turned on and off indicating their print status.
The Consent section needs to be shown for accepted applications that are under 18 years of age. For these we need to validate against two fields, being: accepted and age.
To set up the condition for the Consent section:
The Scripts view now contains three condition scripts, one for each section. Double click the script entry to invoke the wizard dialog.
The scripts reside in the Control group of the Scripts view. Control Scripts run before all other script types and are typically used to control the setup/structure of the template.
Toggle to the Preview mode and browse through the records to see the print status decorator of the sections turn on and off based on the value of the admitted field.
Receive exclusive OL products news, tips and resources.
Your email address will not be published. Required fields are marked *
Notify me of followup comments via e-mail. You can also subscribe without commenting.