Hi,
I want to hide this activate/deactivate button for all users except system admins. How can I achieve this using the ribbon workbench?
Thanks,
Prajwal
Hi,
I want to hide this activate/deactivate button for all users except system admins. How can I achieve this using the ribbon workbench?
Thanks,
Prajwal
It's working now. Thank you, Steve !!
Hi ,
Thanks for the clarification.
Hi Prajwal Bhetwal,
Its role name should be "System Administrator". So try the following code:
function hasCurrentUserRole(roleName){ let hasRole = false; let roles = Xrm.Utility.getGlobalContext().userSettings.roles; roles.forEach(x => { if (x.name === "System Administrator") { hasRole = true; return; } }); return hasRole; }
And the rule should be tied to the button command.
Steps:
1. Right click the ‘DEACTIVATE’ button and open the 'Customise Command':
2. Then add your custom enable rule to command:
3. Finally, publish your solution.
Hi,
Display name of the system admin role should be "System Administrator" so compare it with that, you can also debug your code.
Hi
That didn't work either.
Here's what I did:
2. Created a new solution in environment and added an account entity with no data in it.
3. Loaded that solution in ribbon workbench
4. Selected the Deactivate button and added an enable rule
5. Published the solution
6. Tested using an account that is not a system admin user
What am I missing?
Hi Prajwal Bhetwal,
If so, you could try to check the security name other than id. Please use the JS in the following blog to replace it:
Dynamics 365: Check if the current user has specific role - WareTec
This solution works OK if we are dealing with only custom security roles. We have a problem here if we need to check the logged-in user roles with any out-of-box security roles(System Administrator). The GUID of out-of-box roles are different in a different instance. So, the JS will not work.
Hello,
Prajwal Bhetwal
You have to create java script and add it into ribbon work bench enable rule .
Hope this link will help you.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156