Conditional Print sections

You can include or exclude entire Print sections from the output, depending on a field’s value. This can be done using the Conditional Print Section Script Wizard, described below. Alternatively you could write a Control Script (see Control Scripts).

Including or excluding Print sections using the Conditional Print Section Script wizard

To open the Conditional Print Section Script wizard:

  • Right-click the section and click Make Conditional.

  • Alternatively click the black triangle on the New button on the Scripts pane at the bottom left of the window, and click Conditional Print Section Script. Double-click the new script to open the Conditional Print Section Script wizard.

In the wizard, first make the following settings.

  1. Rename the script so that it reflects what the script does.

    Scripts can only have the same name when they are not in the same folder. (See Managing scripts.)

  2. Select the section you want to put a condition on.

  3. Set the Action: Print or Skip that is performed when the condition below is true. The opposite action is applied when the condition returns false.

Once these settings have been made, the condition can be build.

The Add button adds a rule that evaluates a data field to a group.
To add either a group, or a rule that evaluates a runtime parameter, click the downward pointing arrow next to this button and select Group or Parameter Rule.

Creating a parameter rule is only possible if the template contains runtime parameters; see Runtime parameters.

The rule(s) apply at a Group level. There may be one rule or many rules at the same level, and there may be groups within groups, providing the ability to create quite complex nested logical structures.

Group

A group consists of one or more rules with a logic operator. Four logic choices are available at the Group level. These are:

  • All of the following.
    This equates to the logical operator (... AND ...).
    If all of the associated criteria are met, then this group resolves to TRUE.

  • Any of the following.
    This equates to the logical operator (... OR ...).
    If any of the associated criteria are met, then this group resolves to TRUE.

  • Not all of the following.
    This equates to the logical operator (NOT(... AND ...)).
    If any (but not all) of the associated criteria are met, then this group resolves to TRUE.

  • Not any of the following.
    This equates to the logical operator (NOT (... OR ...)).
    If none of the associated criteria are met, then this group resolves to TRUE.

The top level is always a group. A group can contain one or more Rules and/or Groups.

Rule

A single rule evaluates one data field or runtime parameter using a single operator or function and a value (the "operand").

To construct a rule:

  1. Click the downward pointing arrow next to Field, then select the data field or runtime parameter that should be evaluated.
  2. Select the operator. The downward pointing arrow expands the list of operators with which the data can be evaluated.
    The options available will depend upon the Data Field or Parameter type (they are "type aware"), but most have at least "is equal to" and "is not equal to" as an option. For the complete list of options per data type see Conditional Content script dialog.
  3. Enter the Value that should be used for the conditional check.
    • Values (in Strings) are case sensitive by default; you can click the button next to the value to make them case insensitive.
    • Dates should be entered in ISO standard notation (yyyy-mm-dd) (see ISO 8601). It is best to select the date using the date selection option.

It isn't possible to enter more than one value in one rule. Comparisons to multiple values can be made by combining rules in a group.
For example, an "after" and "before" rule combined in one "all of the following" group can be used to check whether a date falls between two dates.

To save the script, click Apply or OK.

The selected action will be performed if the joint groups and rules evaluate to true.
If, conversely, the condition evaluates to false, the opposite action will be performed.

To see the result, toggle to the Preview tab at the bottom of the workspace (or select View > Preview View on the menu).

If a condition cannot be made with the wizard - for example, one that compares a data field to a runtime parameter value - you can click Expand and edit the code of the script (see Writing your own scripts). But be careful: once the script has been altered, there is no going back to the wizard.
Take a look at the Resources pane: on each Print section that is affected by a Conditional Print Section script a small decorator appears if it is skipped with the current data record.