Back to all How-tos

Output Sections conditionally

The case we deal here is the one where the sections are output according to a data field value condition.

For example, we have three sections named respectively Letter-Volley, Letter-Promo and Invoice. The data field Preference allows us to control what section should be executing based upon its value. So, if the data field Preference value is equal to Volleyball then the Letter-Volley and the Invoice sections are outputted, else the Letter-Promo and Invoice sections are outputted.


  1. In the Scripts pane, add a Control Script
  2. Open the Control Script and write the following lines:
    var lettertype = record.fields.Preference;
    if (lettertype == 'Volleyball'){
    merge.template.contexts.PRINT.sections['Letter-Promo'].enabled = false;
    else {
    merge.template.contexts.PRINT.sections['Letter-Volleyball'].enabled = false;

In order to test this concept, you can download and open the following resources which are taken from the ‘Connect Foundations’ course.

To see the Control Script above in action, toggle to the Preview tab in the template view and go through the different records. Notice that a red indicator appears next to the letter/document (in the Resources pane, under Contexts > Print) that is disabled by the script depending on the value of the Preference field.

API Features used in this how-to

Leave a Reply

Your email address will not be published. Required fields are marked *