We can easily override component properties based on user roles. This can come in handy when you have multiple users and roles in your application.
Example: Overriding button text based on role
In this example, we have a button with the text,
Sign in. We want to override this text to
Sign in as Manager based on whether the logged in user has the
Manager permission or not.
Enable Access Management
In order to enable access management, navigate to the Project Settings and opt for Access Management
- Enable login for your project.
- Create a new permission under Permissions tab and label it as
- Create a new role under Roles tab and label it as
Manager. Add the the
DELETEpermission for this role.
- Create two users, one with the
Managerrole and one without.
Configure the button
- Drag and drop the button component onto the canvas.
- Add the button text as
Add the override
- Open the
Overridestab for the button.
- Click on
+ Overrideto add a new override.
- Add the expression to apply the override only if the user permission includes the
DELETEpermission, which for our case is only applicable to the
Managerrole. The expression would look like
- Choose the property to override as
- Make the Text property
Sign in as Managerfor the override.
- Deploy the application.
- Log in with the user with
- Observe that the button should have
Sign in as Managertext.
- Log in with the user without the
- Observe that the button should only have the text as