Insert Conditional Text Into an RTF Form Template

You can specify that certain text is only shown when a particular condition is met. Both simple conditions and multiple conditions are supported in RTF form templates. Conditional text can be achieved by:

Tip: Conditional text in forms is demonstrated in the Healthy Eating, Insurance Picker, myBenefits, Parental Leave Calculator and Safety Inspection example projects installed with Policy Modeling.

Insert conditional text using the Conditional Region dialog

The Conditional Region dialog can be used when the condition is that an attribute equals a value. It can also be used for greater/less than comparisons for number attributes provided you select 'Number' from the drop-down list.

To insert conditional text using the Conditional Region dialog:

  1. In your template, select the text that you would like displayed under certain conditions.

    Text in a form template before conditions added
  2. Click on the Conditional Region button on the Publisher ribbon:

    Conditional Region button on BI Publisher ribbon
  3. In the Conditional Region dialog, on the Properties tab in the General box:
    1. In the Data field drop-down list, select the attribute whose value you want to base the condition on.
    2. Select the attribute type from the drop-down list. Note: These are Analytics Publisher types so use "Number" for Intelligent Advisor number attributes and "Date/Text" for Booleans and for all other attribute types including currency.

      BI Publisher Properties for conditional region with general data field specified including type

  4. In the Condition 1 box:
    1. In the Data field drop-down list, select the condition that applies to the attribute.
    2. Type in the condition value (formatted).

      BI Publisher Properties for conditional region with condition specified including value

  5. Click OK. The following Analytics Publisher fields will appear around the conditional text in your template (C stands for Condition, EC stands for End Condition).

    A conditional region using abbreviated display text in a form template
  6. (Optional) To make it evident in the form template what the condition is (without having to open up the Properties dialog), you can change the display text. To do this:
    1. Double-click on the C (condition) in the template to open the Oracle Analytics Publisher Properties dialog box. (If double-clicking the field does not open the dialog, re-load your XML.)
    2. Click on the Advanced tab.
    3. Select the code text and copy it (Ctrl+C), then paste it (Ctrl+V) into the Text to display field.

      Updated display text for condition on the Advanced tab of the BI Publisher properties dialog
    4. Click OK.
    5. Repeat this process for the E (end condition).

    The conditions are now shown around the conditional text in your template.

    A conditional region using non-abbreviated display text in a form template

An example of conditional text inserted into a template is:

Form template showing conditional text fields

The resulting form when the paternity leave application is for an adoptive parent would look like this:

A generated form showing conditional text inserted

The resulting form when the paternity leave application is for a natural parent would look like this:

A generated form showing conditional text inserted

Insert conditional text manually

You can manually define your own conditional region by following the format described below.

Simple conditions take the following format:

  • <?if:condition?>Display text when condition met<?end if?>

Multiple conditions take this format:

  • <?choose:?><?when:condition?>Display text when condition met<?end when?>
    <?otherwise:?>Alternate display text<?end otherwise?><?end choose?>

Tip: Multiple conditions in forms are demonstrated in the Healthy Eating, myBenefits and Safety Inspection example projects installed with Policy Modeling.

Note that the conditions in these elements use Unformatted Attribute Values and need to follow a particular syntax (see examples Analytics Publisher code for Policy Modeling for more information).

To manually insert simple conditional text:

  1. Create the start of the condition. To do this:
    1. Insert a field for the condition attribute value into your template.

      The Field dialog in Analytics Publisher showing the selection of an attribute value
    2. Double-click on the field in the template.
    3. In the Oracle Analytics Publisher Properties dialog box:
      1. On the Advanced tab, enter the code for the start of the condition (for example, <?if:attribute_name/value='value'?>).

        Start tag for conditional text coded on Advanced tab in the BI Publisher Properties dialog
      2. Select the code text and copy it (Ctrl+C).
      3. On the Properties tab, paste it (Ctrl+V) into the Text to display field.
      4. Click OK. The start condition is now shown in your template.

        The start of a condition in a form template
  2. Add the text that you want displayed conditionally. To do this:
    1. After the start condition in your template, enter the text that you want to be displayed when the condition is met.

      The start of a condition in a form template with the text to be displayed conditionally added
  3. Create the end of the condition. To do this:
    1. After the display text, insert another field for the condition attribute value into your template.
    2. Double-click on the field in the template.
    3. In the Oracle Analytics Publisher Properties dialog box:
      1. On the Advanced tab, enter the code for the end of the condition, that is, <?end if?>.

        End tag for conditional text coded on Advanced tab in the BI Publisher Properties dialog

      2. Select the code text and copy it (Ctrl+C).
      3. On the Properties tab, paste it (Ctrl+V) into the Text to display field.
      4. Click OK. The end condition is now shown in your template.

        The end of a condition in a form template

    An example of conditional text inserted into a template is:

    Form template showing conditional text fields

    The resulting form when the condition is true would look like this:

    A generated form showing conditional text inserted

Formatting of conditional text

By default, the conditional text will appear on a new line because Analytics Publisher applies the instructions to the block. If you want the conditional text to appear on the same line as the text that precedes it, you need to include @inlines in your if syntax.

For example, <?if:@inlines:improvements/value='true'?>.

For more information, see Use Conditional Formatting in Designing and Publishing Pixel-Perfect Reports in Oracle Analytics Server.