- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have a button on a UI Builder page that I only want to show if the current user does not have any of the roles such as "sn_grc.business_user_lite" and "sn_risk.manager"
Can anyone explain how I could achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
@Biddaum ,
follow the same process mentioned above, just change the script
/**
* @param {params} params
* @param {api} params.api
* @param {TransformApiHelpers} params.helpers
*/
function evaluateProperty({
api,
helpers
}) {
var currentUserRoles = api.context.session.user.roles;
if (currentUserRoles.includes('sn_grc.business_user_lite') ||
currentUserRoles.includes('sn_risk.manager')) {
return true;
}
return false;
}Now try out this script and check.Now the button is not visible if the user is having either any of the roles otherwise it will not visible.
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
an hour ago
Hi @Biddaum ,
Open the page in UI Builder and click on the button you are taking about and on the right under configuration panel ,You will find component visibility hover on the hide component property you will observe the data bind symbol .Click on that ,
Then click on the <> icon (use script) as shown in the below image
Insert the following script there,
/**
* @param {params} params
* @param {api} params.api
* @param {TransformApiHelpers} params.helpers
*/
function evaluateProperty({
api,
helpers
}) {
var currentUserRoles = api.context.session.user.roles;
if (!currentUserRoles.includes('sn_grc.business_user_lite') &&
!currentUserRoles.includes('sn_risk.manager')) {
return false;
}
return true;
}Now click on save and observe that if the user doesn't have both the roles then the button should visible.If the user had atleast one role then the button will not visible.
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
an hour ago
@Dinesh Chilaka I'm looking for it to be hidden if either role is had by the user, they don't have to have both roles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
@Biddaum ,
follow the same process mentioned above, just change the script
/**
* @param {params} params
* @param {api} params.api
* @param {TransformApiHelpers} params.helpers
*/
function evaluateProperty({
api,
helpers
}) {
var currentUserRoles = api.context.session.user.roles;
if (currentUserRoles.includes('sn_grc.business_user_lite') ||
currentUserRoles.includes('sn_risk.manager')) {
return true;
}
return false;
}Now try out this script and check.Now the button is not visible if the user is having either any of the roles otherwise it will not visible.
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
51m ago
Thanks a heap - works like a charm @Dinesh Chilaka
