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

@Biddaum ,

Don't mine mark it as helpful man

 

Regards,
Dinesh

Ankur Bawiskar
Tera Patron

@Biddaum 

how is that button created?

share some screenshots of the config etc

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader