r/PowerApps•
ventik

How to hide some button in command bar if user does not have System Administrator role?

Power Apps Help

I have a model driven form and I add custom button to main form command bar. But I need to hide it for all users that are not system administrators. How can I do it? I found out how to check if user has this role using JS, but I don't know how to hide button in command bar using JS. And I know how to hide button using Power FX, but I don't know how to check f user has system administrator role.

Here is JS function that checks if user has some role

function userHasRole(roleName) {

const matchingRoles = Xrm.Utility.getGlobalContext().userSettings.roles.get(function(role) {

return role.name === roleName;

});

return matchingRoles.length > 0;

}

Posted Dec 25, 2024, 2:49 PM UTC

638

Comments aren't archived yet

This post had 38 comments on Reddit. Comments for this period haven't been loaded into the archive yet.