In this article we will look into different ways of writing the IF condition in RTF template to achieve complex requirements.
Every BIP or HCM Extract will have a template tagged to them to get the output in different formats.. RTF is the most common template to get the output in PDF/HTML/Excel.
If there is a requirement to write conditional logic in RTF template, then IF condition can be used in such cases. Mostly in case of letters (Offer Letter/Appraisal Letter) to conditionally skip/display some paragraphs and also in regular templates when there are condition based calculations.
Table of Contents
Use If statement directly in the template as Text or form field
<?if:FLAG_1=’Y’?> Yes <?end if?>
Use If else statements using xdofx command
<?xdofx:if SALARY > 10000 then 'Salary More than 10K' else 'Salary less than 10K' end if?>
Nested If Sample using xdofx
<?xdofx:if ../../../PAYMENT_DETAILS/PAYER_METHOD/PAYMENT_METHOD_NAME = 'RRSP Cheque' then ( if instr(../../../PAYMENT_DETAILS/THIRD_PARTY_DETAILS/THIRD_PARTY_BREAKDOWN/GLB_ARCH_TPP_PAYMENTS/GLB_PAY_ARCH_TPP_ADDRESS/TPP_PAYEE_NAME,'-',1,1) > 0 then substr(../../../PAYMENT_DETAILS/THIRD_PARTY_DETAILS/THIRD_PARTY_BREAKDOWN/GLB_ARCH_TPP_PAYMENTS/GLB_PAY_ARCH_TPP_ADDRESS/TPP_PAYEE_NAME,1,instr(../../../PAYMENT_DETAILS/THIRD_PARTY_DETAILS/THIRD_PARTY_BREAKDOWN/GLB_ARCH_TPP_PAYMENTS/GLB_PAY_ARCH_TPP_ADDRESS/TPP_PAYEE_NAME,'-',1,1)-1) else ../../../PAYMENT_DETAILS/THIRD_PARTY_DETAILS/THIRD_PARTY_BREAKDOWN/GLB_ARCH_TPP_PAYMENTS/GLB_PAY_ARCH_TPP_ADDRESS/TPP_PAYEE_NAME ) else ../../GLB_PAY_ARCH_EE_INFO/DISPLAY_NAME ?>
If else condition using xdoxslt
Sample to display different field value based on a field value
<?xdoxslt:ifelse(BASE_NAME = 'HOURS',VALUE,CAL_VALUE)?>
Use choose statement if there are multiple conditions
<?choose:?> <?when: COMPANY=111?>Legal Entity 1<?end when?> <?when: COMPANY=222?>Legal Entity 2<?end when?> <?when: COMPANY=333?>Legal Entity 3<?end when?> <?otherwise?>Legal Entity 4<?end otherwise?> <?end choose?>
Using OR and AND conditions in the IF statement:
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
<?if:XMLfield=value1 or XMLfield=value2?> display Calue <?end if?>
<?if:(sum(VALUE)=0 or sum(AMOUNT)=0)?>0<?end if?>
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:((MEMBER='N' and SALARY_BASIS_CODE='HOURLY') and (ASG_CAT='Full-time' or ASG_CAT='Part-time') and (CITY='Las Vegas' or CITY ='Laughlin'))?>
Note: Make sure you use braces for the entire condition & ensure that or & and are used in lower case to make the condition work perfectly.
Hope this is useful. You can use any of the above methods depending on your requirement.
Top 10 Popular Posts from our Knowledgebase
- DataFusing FREE Cloud based SQL Developer like tool for Oracle Cloud
- Core HR Entity Relationship Diagram (ERD) for HCM Cloud
- Most Frequently used Document IDs from Oracle Support
- FREE Oracle Training & Accreditation with Oracle Learning Explorer
- How HDL Transformation Formula works with ElementEntry Sample
- FREE Oracle Fusion Demo Instance (VISION) Access
- Top 10 FREE useful tools for Fusion Consultants
- Learning Fusion HCM Technical Skillset
- Sample HCM Data Loader (HDL) files for all Business Objects
- Most frequently used Tables list in Fusion HCM