Show/Hide ribbon button based on security role using “EntityPrivilegeRule” in Dynamics 365 CE (Without writing code).
In my last post I was discussing about how to hide Ribbon button using “MiscellaneousPrivilegeRule” without writing any code or creating any entity, we always prefer to do things better way, but sometimes for that we may need to maintain additional things. Similarly, to show/hide ribbon button you can easily do based on security role by using Dynamics 365 Display Rule, but for that we need to depend on some entity privilege. For example, let say you want to hide certain button only if the entity has at least user level “CREATE” access. In this article I am going to show that.
Here is my scenario, I don’t want to do “Sale Managers” users to close an open opportunity as won. So, to that we need to hide “Close as won” button for all the user assigned “Sales Manager” Role.
In this context as I mentioned we need to depend on some dummy entity, here I have created one dummy entity called “new_buttonaccess” and I will give at least user level ” CREATE” access to perform opportunity “Close as won” and if the user does not have any “CREATE” access user won’t be able to perform opportunity “Close as won” which means user can’t see “Close as won” button.
Here is my display rule, I selected Default = true with condition I have mentioned PrivilegeDepth =Basic and PrivilegeType= Create, which means user only can see the button if user having “new_buttonaccess” entity user level “CREATE” acc. Creating an entity having an advantage that you can use other privilege like READ, DELETE,APPEND,APPEND TO,SHARE,ASSIGN to do similar logic for any other button to do the same if you have similar requirement.
Now I am going to check “CREATE” access level of “new_buttonaccess” entity for “Sales Manager” security roles . Here you can see I have not given any access, that means “Sales Manager” roles does not see the button “Close as won”.
Here you can see the user assigned “Sales Manager” roles does not see “Close as won” button –
Again, I am going to configure another role called “Vice President of Sales” so that user assigned “Vice President of Sales” can see the opportunity “Close as won” button.
Now I am changing the same user security role to “Vice President of Sales” and see the result.
Now user can see “Close as Won” button.
Hope this helps.
This was originally posted here.
*This post is locked for comments