You are currently viewing How to use EL Expressions to conditionally display/hide fields/icons in Fusion HCM?
How to use EL Expressions to conditionally display/hide fields/icons in Fusion HCM?

In this article we will look into the Expression Language (EL) expressions which are widely used to make fields, regions or buttons visible on the application using Page Composer.

Table of Contents

What is Expression Language?

Standards Java-based scripting language which provides an important mechanism for enabling the presentation layer (web pages) to communicate with the application logic. It is available on both classic and SUI UI’s.

Use cases with Sample EL Expressions

To Conditionally hide/show a particular item in the menu, you may use EL Expression in the Rendered property of the menu item. You can for example set the rendered property of a particular menu item to an EL expression.

Following functions can be accessed from Security Context in EL Expression

#{securityContext.authenticated}
#{securityContext.regionViewable['target']}
#{securityContext.userGrantedPermission['permission']}

Check for User in any one of the Role

#{securityContext.userInRole['role1,role2,roleN']}
#{securityContext.userInRole['ADMIN,MANAGER']}
#{securityContext.userInRole['ORA_PER_HUMAN_RESOURCE_SPECIALIST_JOB']}
#{securityContext.userInRole['ORA_PER_LINE_MANAGER_ABSTRACT'] or securityContext.userInRole['CUSTOM_ROLE']}

When the user has any of the roles, the expression returns True. When the user does not have any of the roles, the expression returns False. The Role Names are case sensitive and should exactly match with whatever is present on the security console.

Check for User in any all of the Roles

#{securityContext.userInAllRoles['role1,role2,roleN']}

When the user has all the roles, the expression returns True. Otherwise, the expression returns False.

Check for User not in Role

#{!securityContext.userInRole['ORA_PER_HUMAN_RESOURCE_SPECIALIST_JOB']}

This is a negative condition because of the negation operator !.

Check for User not in list or Roles

#{!securityContext.userInRole['ORA_PER_LINE_MANAGER_ABSTRACT'] or securityContext.userInRole['CUSTOM_ROLE']}

This is a negative condition referencing multiple roles.

Check for a specific user

#{securityContext.userName=='FUSIONHCMKB'}

When the login user is FUSIONHCMKB, returns True. Otherwise, returns False.

Check for a specific user in list of users

#{securityContext.userName=='FUSIONHCMKB' or securityContext.userName=='SRICHARAN'}

When the logged-in user is SRICHARAN or FUSIONHCMKB, it will return True. Otherwise, it returns False.

Check if the logged in user is not a specific user

#{securityContext.userName !='FUSIONHCMKB'}

When the login user is NOT FUSIONHCMKB, returns True. Otherwise, returns False.

Check condition based on the task flow

#{securityContext.taskflowViewable['target']}
#{securityContext.taskflowViewable['/WEB-INF/audit-expense-report.xml#audit-expense-report‘]} 

Expressions using Profile Values

#{((Profile.values.ZCA_ALLOW_CLASSIC_INTERFACE ne 'Y') or ((not (Profile.values.FND_CLASSIC_INTERFACE eq null)) and (Profile.values.FND_CLASSIC_INTERFACE eq 'N'))) and !(securityContext.userInRole['<RoleName>'])}

It will check for the Profile Values and the User in Role. We need to include the conditions in braces for the OR condition to work perfectly. If we don’t embed them in braces, then the OR condition will be applied to all conditions and you might end up with unexpected results.

Check for User Granted Resource

#{securityContext.userGrantedResource['permission']}
#{securityContext.userGrantedResource['resourceType=FNDResourceType;resourceName=FND_Scheduled_Processes_Menu;action=launch'] or !securityContext.userInRole['OFD_SALES_REP_CUSTOM_JOB,OFD_SALES_MGR_VP_CUSTOM_JOB']}

This checks if the user has been granted with the resource and we can also add additional conditions to skip if the user is in role.

Check by RoleType, PageFlowScope variables

#{(pageFlowScope.pRoleTypeCode == 'MANAGER' and pageFlowScope.pTaskCode == 'MGREVAL' and pageFlowScope.pCustomaryName == 'Performance Document Name')}

Other Consolidated Sample EL Expressions

#{pageFlowScope.pGoalEditMode != 'CREATE_GOAL' &&  (pageFlowScope.pShowPageReadOnly == 'Y' || backingBeanScope.GoalInformationBean.keyAttrReadOnly ||  bindings.StatusCode.inputValue == 'CANCEL' || bindings.StatusCode.inputValue == 'OVERDUE' )} 
#{securityContext.userGrantedPermission['permissionClass=oracle.adf.share.security.authorization.MethodPermission;target=oracle.apps.prc.pon.permission.createSupplierNeg; action=invoke']} 
#{securityContext.taskflowViewable['/WEB-INF/audit-expense-report.xml#audit-expense-report‘]} 
#{row.bindings.IsEmpRatingGiven.inputValue == "Y“ ? true : false} 
#{row.FlowTemplateName == ‘New Hire’ ? ‘color:#0000FF’ : ‘color:#000000’}
#{pageFlowScope.pGoalProfiles['HRG_ENABLE_GOAL_LIBRARY'] == 'Y'}
#{pageFlowScope.accessCode eq 'FULL_ACCESS'? false : true}
#{bindings.GoalPlanAssignmentVO.hints.PriorityCode.mandatory}
#{backingBeanScope.GoalOverviewBean.keyAttrReadOnly}
#{pageFlowScope.pGoalEditMode != 'CREATE_GOAL' && (pageFlowScope.pShowPageReadOnly == 'Y' || backingBeanScope.GoalInformationBean.keyAttrReadOnly || bindings.StatusCode.inputValue == 'CANCEL' || bindings.StatusCode.inputValue == 'OVERDUE' )}
#{pageFlowScope.pReadOnlyDetails || (bindings.MandatoryFlag.inputValue == "Y" ? true : false)}
#{pageFlowScope.mode eq 'R'? false :true}

#{pageFlowScope.hasPayroll eq 'Y'?true:false}

Troubleshooting

  1. If the Role Name is LegalEntity_Administration_NA, then the EL Expression should be written as #{securityContext.userInRole[‘LegalEntity_Administration_NA‘]}
    The following will not work: #{securityContext.userInRole[‘LEGALENTITY_ADMINISTRATION_NA‘]} as the Role Name is case sensitive.
  2. We can use the Test Mode while writing the EL expressions to troubleshoot any issues.
If you like the content, please follow us on LinkedInFacebook, and Twitter to get updated with the latest content.