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.
Table of Contents
The syntax
We can use if condition directly in xml publisher by writingย <?IF?>ย conditionย <?END IF?>
Example: <?if :rate>0 ?> Yes <?end if?>
But for If-else we need to useย extended function.
Method 1:
<?xdofx:if element_condition then result1 else result2 end if?>
Example:
<?xdofx:if PO_AMOUNT > 15000 then โCostlyโ
else
if PO_AMOUNT <5000 then โCheaperโ
else
โEqualโ
end if?>
Method 2:
Syntax:
<?xdoxslt:ifelse(condition,true,false)?>
Example:ย
<?xdoxslt:ifelse(1=2,โyes 1 is equal to 2โ,โNo 1 is not equal to 2โ)?>
The result of the above expression is
No 1 is not equal to 2
if xdoxslt:get_variable
Using this for a variable
for e.g if counter variable is greater than 0 print 22 else print 33
<?xdoxslt:ifelse((xdoxslt:get_variable($_XDOCTX, โcounterโ))>0,22,33)?>
Using OR Condition in XML RTF Template:
Syntax:
<?if:XMLfield=value1 or XMLfield=value2?> display value <?end if?>
Example:
<?if:sum(AVALUE)=0 or sum(BVALUE)=0?>0<?end if?>
Inserting Choose Statements
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.
Use the following syntax for these elements:
<?choose:?>
<?when:expression?>
<?otherwise?>
Recommended post
Variables in BI Publisher RTF template
more on Fusion apps tech