javascriptdynamics-crmmicrosoft-dynamicscrm-ribbon-workbench

Show/Hide Ribbon Button if the user is a System Admin


I have to show/hide ribbon buttons based on whether the user is a System Administrator.

I have figured out a javascript code to do the same. But, on some research, I found out that the same is possible via Display Rules --> Entity Privilege Rule.

But, I cannot find the PrivilegeType as admin. So, am I going on the right path?

Or, writing JS is the only solution?


Solution

  • Your choice - both options are available/possible.

    Developer style (code): Using Enable rule - Custom rule to use javascript code by checking the security roles of current user & perform show/hide based on return flag.

    Admin style (no-code): Using Display rule - Entity privilege rule to identify one particular entity (any entity) where only particular role (let’s say Sys.Admin) has that particular privilege type (eg. Create) & privilege depth (eg. Global). Read more

    There’s no Admin type of privilege available.

    Note: Enable rule also show/hide just like Display rule after command bar introduced in 2013. Before that ribbon button will be shown as disabled that’s why we have two different components.