If/End If Statements
Create If Statement
- Drag and drop the variable data field from the Field menu into your Microsoft Word template. This field should be placed at the beginning of the optional text. For this example, the ADMIT_TYPE field is used to illustrate the steps needed to add conditional logic.
- Double-click on the data field to bring up the BI Publisher Properties window.
- Enter a name for the conditional data statement you are creating in the Text to display field.
- The Text to Display name is the value that displays on the template, replacing the name of the field you dragged into the template. For example:
- The example above references the letter B prior to the field name (B.ADMIT_TYPE). This indicates the order in which additional database tables were selected to retrieve data and could vary depending on each specific communication and data source.
- When building If statements, it is recommended you start the name with "If". For example, "If Transfer", or "If Non US". This makes it easier to follow logic statements when viewing your template.
- Click the Advanced tab on the BI Publisher Properties window.
- Enter your If statement in the Code field. The field is formatted as: <?if:field_name='true statement'?>. For example: <?if:B.ADMIT_TYPE='4'?>, where B.ADMIT_TYPE is the field name and 4 indicates a transfer student.
View example of an If statement - Click OK.
Create End If Statement
- Drag and drop the same variable data field from the Field menu into your Microsoft Word template, placing it after the optional text.
- Following the example above, you would select B.ADMIT_TYPE from the list of field options.
- Double-click on the data field to bring up the BI Publisher Properties window.
- Enter a name for the End If conditional data statement you are creating in the Text to display field.
- It is recommended you name the End statement "End <If statement>". For example, "End If Transfer", or "End If Non US". This makes it easier to follow logic statements when viewing your template.
- Click the Advanced tab on the BI Publisher Properties window.
- Enter <?end if?> in the Code field.
- Click OK.
When completed, your optional text should have an If statement at the beginning and an End If statement at the end:
If/Not If Statements
If/Not If statements allow you to display a block of text to specific recipients, while displaying a different block of text to all other recipients. For example, all current applicants may need a communication with additional application verbiage. However, one of the statements is different for transfer student applicants. Instead of creating two different communications, you can enter all the potential verbiage in one communication and use If/Not If statements to define which verbiage is included.
Before beginning work in your template, determine which data field and values need to be used in the statement. In the previous example, the text being displayed depends on the applicant being defined as a transfer student or non-transfer student. This is defined in the ADMIT_TYPE field. Your first condition (If statement) would then be anyone with ADMIT_TYPE of 4 (transfer student code), and the second condition (If not statement) would be for all other recipients.
Create If Statement
Follow the procedure steps in the If/End If Statements section. Insert the If/End If tags at the beginning/end of the text that is specific to the indicated group.
Create If Not Statement
The If Not tags need to be placed at the beginning/end of the text that is specific to everyone not in the previous group.
- Drag and drop the variable data field from the Field menu into your Microsoft Word template. This field should be placed at the beginning of the optional text. For this example, the ADMIT_TYPE field is used to illustrate the steps needed to add conditional logic.
- Double-click on the data field to bring up the BI Publisher Properties window.
- Enter a name for the conditional data statement you are creating in the Text to display field.
- The Text to display name is the value that displays on the template, replacing the name of the field you dragged into the template. For example:
- The example above references the letter B prior to the field name (B.ADMIT_TYPE). This indicates the order in which additional database tables were selected to retrieve data and could vary depending on each specific communication and data source.
- When entering the Text to Display name on the BI Publisher Properties window, it is recommended the name start with "If Not". For example, "If Not Transfer". This makes it easier to read and understand the data fields on the template.
- Click the Advanced tab on the BI Publisher Properites window.
- Enter your If Not statement in the Code field. When entering the Code on the BI Publisher Properties window, the field format is <?if:not(field_name='true statement')?>. For example: <?if:not(B.ADMIT_TYPE='4')?>, where B.ADMIT_TYPE is the field name and 4 indicates a transfer student.
View example of an If Not statement - Click OK.
Create End If Not Statement
- Drag and drop the same variable data field from the Field menu into your Microsoft Word template, placing it after the optional text.
- Following the example above, you would select B.ADMIT_TYPE from the list of field options.
- Double-click on the data field to bring up the BI Publisher Properties window.
- Enter a name for the End If Not conditional data statement you are creating in the Text to display field.
- It is recommended you name the End statement "End <If Not statement>". For example, "End If Not Transfer", or "End If Not Non US". This makes it easier to follow logic statements when viewing your template.
- Click the Advanced tab on the BI Publisher Properties window.
- Enter <?end if?> in the Code field.
- Click OK.
When completed, there should be two text blocks, each with the appropriate If and End if statements:
Using Data Field Substrings
When building If statements, you need to know the data values which drive your conditions, such as Term Description = Fall 2016. In cases like this, the data value is text, not a code, and may change year to year. Using substring conditions allows you to write If statements that do not require regular maintenance.
Example
You are writing a communication that includes an If statement based on a term, such as Winter or Fall. These fields include a specific year - Fall 2016, Winter 2017. If you included the year in the If statement (D.DESCR='Winter 2017'), you would have to change the code in your letter every year. Instead, you can use the substring to read the first few characters of the string ('Wint', 'Fall'), a value which stays the same every year.
On the BI Publisher Properties menu, the Code is formatted as:
<?if: substring(<field_name>, <start place in string>,<number of characters to read>)='value'?>
To build the string, you need to know the field name, where in the string to start looking for the value, how many characters to read, and the value:
<?if: substring(D.DESCR, 1,4)='Wint'?>
This string means that in the D.DESCR field, start at the first letter (1) and read four characters (4). The If condition would be fulfilled if the data selected for a student returned those four characters as 'Wint'.
Date Formats
When using date fields in your template, you can change the format in which it displays.
- Drag and drop the date field into the Microsoft Word template.
- Double-click on the field in the template to bring up the BI Publisher Properties window.
- From the Type drop-down menu, select Date. View date settings on the BI Publisher Properties window
- From the Format drop-down menu, select desired date format. For example, MMMM d, yyyy, or yyyy-MM-dd).
- "MMMM d, yyyy" translates the date into the full month description, a one- or two-character day value, followed by the year, i.e., January 16, 2016.
- (Optional) Enter an example of the date in the Text to display field. This replaces the field name in your template with your example date, providing a visual cue that you have included a date in your template.
- The date entered in the Text to display field is not the actual date the communication recipient sees. The date in the communication is pulled from the variable field.
- The Text to display field is intended for a sample date only and does not accept letters or words, such as "Due Date".
Field Browser
All the logic statements in a template can be viewed on the Field Browser window. Select Field Browser from the BI Publisher > Tools menu. Click Refresh and/or Show All to update the list.
View the Field Browser