How do I make a field show or hide based on a User's Role?
Step-by-step guide
- Select the Module link in the top left banner then select the appropriate module name link.
- Select the Forms tab.
- Then select the Field List button "Create/Update Fields".
- Select the field that you want to conditionally show or hide.
- Select the Edit pencil icon on the field.
- In the Display Condition Field enter a Custom JavaScript expression like the examples below that evaluates True when the field should show:
Example- Show for "example-role", "module admin", and "tenant admin" use the below conditions
isInRole('example-role') || isInRole('module admin' ) || isInRole('tenant admin')
Example- Not show for a specific role, use the below condition
!isInRole('example-role') - Once you have entered all desired options click the Update button and then click Save on the Field List.
- To test, load the request form as the respective roles to ensure the field either shows or does not show as desired.
Related articles