Erik van den Heuvel
October 7th, 2021
When creating personalized documents one often needs to make decisions based on data. A common example is showing/hiding one or more paragraphs depending on a field’s value. To achieve this OL Connect Designer 2021.1 comes with a wizard to simplify setting up these conditional elements. It allows conditions to check 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).
In this example you’ll learn how to conditionally show one or more
paragraphs based on data. It is a simple way to toggle information while
the overall look and feel of the letter is untouched. Note that
conditions are not limited to paragraphs they can be set for any element
including headings, images, tables and divs.
The following image shows a letter from an insurance company. The conditional elements are marked with a background color (yellow, blue and red).
The yellow element should be shown when the model_name data field is set to request-for-contact. The blue paragraph is shown when the respective field is set to file-reassignment and the red paragraphs when it is set to denial-no-coverage.
To turn the yellow paragraph in a conditional element:
Tip! Entering a meaningful name for the script will help you to identify it in the Scripts view.
By default the wizard assigns a unique class name (hence the dot prefix: .conditional-script)
to the element. This is used by the script to locate the element when
it needs to apply the logic. On the initial invocation of the wizard one
can overwrite the default selector with a custom value. The value will
be assigned to the element and used for the Selector of the script.
Note! In case the element already had an class name and/or ID the wizard will use that information.
The same steps are used to create a conditional script for the blue paragraph but with a different value for the model_name.
For the red text the approach is slightly different as it entails two
paragraphs for which the visibility is driven by the same data field.
The easiest approach is to assign both paragraphs the same CSS class
name before invoking the wizard.
To set the class name for the paragraphs:
To make the paragraphs conditional:
The new script targets all elements with the .denial-no-coverage class name. As we’ve set this class to both red paragraphs both entries will be shown/hidden by the same script.
The above scenario shows an example to show/hide elements based on a
single value. The new wizard allows you to add one or more fields to
create more complex conditions.
The available conditions depend on the field type. For boolean fields you will be able to check if the value is true or is false and for integer fields you’ll find conditions like Greater than and Less than but also Greater than or equal to and Less than or equal to.
The green plus icon allows the user add Field rules but also rules for runtime Parameters (set via Workflow) and sub-conditions using Groups.