Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

UI Builder only show button if role is missing

Biddaum
Tera Guru

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?

1 ACCEPTED SOLUTION

@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.

View solution in original post

6 REPLIES 6

Dinesh Chilaka
Tera Guru

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 ,

Screenshot 2026-03-12 at 8.44.33 AM.png

Then click on the <> icon (use script) as shown in the below image
Screenshot 2026-03-12 at 8.46.42 AM.png

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.

@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

@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.

Thanks a heap - works like a charm @Dinesh Chilaka