When condition in rtf template?
Use If statement directly in the template as Text or form field
Use If else statements using xdofx command
Nested If Sample using xdofx
If else condition using xdoxslt
Sample to display different field value based on a field value
Use choose statement if there are multiple conditions
We have to be very careful with the syntax of the statement that we write when we use the OR and AND commands as they don’t work if we don’t follow the proper syntax
Syntax:
Example:
We need to enclose the total condition in braces ( and ).
The operators or & and should be in lower case only else they won’t work properly.
If there are multiple conditions based on which some text needs to be shown it can be written as below using and & or conditions.
- If statement:
- if:condition?>
- Insert the following syntax at the end of the conditional area: end if?>
- if:DEPTNO=10?>
- end if?>
- IF COMM IS NULL THEN 'N'
- ELSE 'Y'
- END IF.
If
if-then-else
choose- when-otherwise
The Conditional Formatting using if statement:
If statement:
Use if statement to define a simple condition; for example, if a data field is a specific value.
Insert the following syntax to designate the beginning of the conditional area.
Insert the following syntax at the end of the conditional area:
For example display 10th department employees
BI Publisher supports the common programming construct “if-then-else“. This is extremely useful when you need to test a condition and conditionally show a result
IF COMM IS NULL THEN ‘N’
ELSE ‘Y’
END IF
Output:
Choose- when-otherwise statement:
Use the choose, when, and otherwise elements to express multiple conditional tests. If certain conditions are met in the incoming XML data then specific sections of the template will be rendered. This is a very powerful feature of the RTF template. In regular XSL programming, if a condition is met in the choose command then further XSL code is executed
Use the following syntax for these elements:
Example:
Ten
Twenty
Thirty
N/A
Output:
When you create a BI Publisher template, you can add conditional statements to determine whether or not a condition is true or false. IF Condition in RTF template allows you to perform actions only when certain conditions are met. For example, you might want to display a message only when the value of a field exceeds a certain threshold.
We can use if condition directly in xml publisher by writing condition
But for If-else we need to use extended function.
Method 1:
Example:
Method 2:Syntax:
Example:
The result of the above expression is No 1 is not equal to 2
Using this for a variable
for e.g if counter variable is greater than 0 print 22 else print 33
Use the choose, when, and otherwise elements to express multiple conditional tests. If certain conditions are met in the incoming XML data, then specific sections of the template are rendered. This is a very powerful feature of the RTF template.
Recommended post
Variables in BI Publisher RTF template
Bursting in Fusion BIP