- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi All,
I am working on a Configurable Workspace page in UI Builder where I have multiple tabs, including a Playbook tab. My requirement is to show the Playbook tab only for users who have a specific role.
Role:
xyz
Requirement:
- If the logged-in user has the above role, the Playbook tab should be visible.
- If the user does not have the role, the Playbook tab should be hidden.
What I Tried:
- I added a visibility script in the Playbook tab settings in UI Builder.
function evaluateProperty({api}) {
if (api.user.hasRole('xyz')) {
return true;
}
return false;
}- I also tried checking user roles using:
function evaluateProperty({api, helpers}) {
let user_roles = api.context.session.user.roles;
let visibility_condition = user_roles.includes('xyz');
return visibility_condition;
}Issue:
Even after applying the script, the Playbook tab is still visible for users who do not have the role.
Questions:
- Is the tab visibility controlled differently in Configurable Workspace?
- Is there a recommended way to restrict tab visibility by role?
Any suggestions or best practices would be helpful.
Thanks in advance.
Anitha P
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@u499207 ,
It returns true means ,the user contains the role xyz, then the tab will be visible.If the user doesn't contain the role means it will return false,then tab will get hidden.
Check out with the user who are not having xyz role.
If my response helped,mark it as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@u499207 ,
Try once printing all the roles in the Console and check whether that role is present for different users or not.
function evaluateProperty({api, helpers}) {
let user_roles = api.context.session.user.roles;
console.log("User Roles ". + JSON.stringify(user_roles));
let visibility_condition = user_roles.includes('xyz');
console.log(visibility_condition);
return !visibility_condition;
}
Thanks,
Dinesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Dinesh Chilaka ,
It returns true, but the Playbook tab is still visible.
Thanks,
Anitha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@u499207 ,
It returns true means ,the user contains the role xyz, then the tab will be visible.If the user doesn't contain the role means it will return false,then tab will get hidden.
Check out with the user who are not having xyz role.
If my response helped,mark it as helpful and accept the solution.
