Control Display of Add Action in Personal Info Pages Based on User Role
In this example, let’s learn how to display the Add action in Personal Info pages based on user roles using conditions.
The conditions are limited to whether the user is viewing their own record or another person's record, or the user has a specific role assigned. For example, you want to show the Add action in the Address region on the Contact Info page to the HR professionals but want to hide it for employees.
Let's look at the steps to achieve this requirement.
- Click .
- Click the person name.
- From the Setting and Actions menu, click Edit Page in Visual Builder Studio
- Select an existing project or create a new one.
- Ensure you're in Express mode.
- In the Page Properties pane, search or navigate to the Show Add Icon in the Address Section page property and enter [[ $base.variables.ElevatedUser.includes('OTHERS') ? 'Y' : 'N' ]] to show the field.
- Preview and publish your changes. You can preview the Contact Info page from both the My Client Groups tab where you can see the Add action, and from the Me tab where you won't see the action.
Here’s a list of condition examples that you can use to show or hide the Add action.
Condition | Display the Add Action | Hide the Add Action |
---|---|---|
A professional user from the 'Me' context | [[ $base.variables.ElevatedUser.includes('OWN') ? 'Y' : 'N' ]] | [[ $base.variables.ElevatedUser.includes('OWN') ? 'N' : 'Y' ]] |
A professional user from the 'My Client Group' context | [[ $base.variables.ElevatedUser.includes('OTHERS') ? 'Y' : 'N' ]] | [[ $base.variables.ElevatedUser.includes('OTHERS') ? 'N' : 'Y' ]] |
Specific User Roles | [[ $application.user.roles.includes( 'ROLE_1' , 'ROLE_2' , .... ) ? 'Y' : 'N' ]] | [[ $application.user.roles.includes( 'ROLE_1' , 'ROLE_2' , .... ) ? 'N' : 'Y' ]] |
To hide the action for all users, set the page property to N.