Show/Hide Buttons Based on Entity Permissions Using Power FX
Recently, we received a client requirement to show a button to users who have the Create permission for a specific entity. In the traditional approach, we would use the Ribbon Workbench in XrmToolBox to add buttons and write JavaScript code to check user permissions. While this method works fine, it can be a bit complex and technical.
After doing some research and exploring Microsoft Docs, we found a Power Fx formula:
DataSourceInfo({EntityName},DataSourceInfo.{Permission})
This formula checks the Table (Entity) permission. By using the Power Fx formula, we can easily control the visibility of the button based on permissions. This method is much simpler.
How to Implement This in Dynamics 365
1. Create a New Button: Using the Command Bar Editor in Dynamics 365, create a new button that we need to hide or show based on privileges.
For more detailed guidance, refer to the Customize the command bar using command designer.
2. Set Button Properties: In the properties of the newly created button, go to the Visibility section and select “Show on Condition from Formula.
3. Add the Formula: For example, if we want to show a button only if the user has Create permission for the Account entity, we use the DataSourceInfo function with Create Permissions in the Power FX formula....Read more>>
The post Show/Hide Buttons Based on Entity Permissions Using Power FX first appeared on Microsoft Dynamics 365 CRM Tips and Tricks.
This was originally posted here.
*This post is locked for comments