Hi,
To conditionally show or hide the Edit button in a model-driven app based on user roles and field values, you’ll need to use Ribbon Workbench along with JavaScript. Here's a general approach to get started:
Use Ribbon Workbench: This tool allows you to customize command bar buttons. You can define display rules and enable rules based on JavaScript functions.
Create a JavaScript Web Resource: Write a function that checks:
status
Example snippet:
function shouldShowEditButton(formContext) { var status = formContext.getAttribute("status").getValue(); var userRoles = Xrm.Utility.getGlobalContext().userSettings.roles; var hasRole = userRoles.some(function(role) { return role.name === "YourRoleName"; }); return !(hasRole && status === "Complete"); }
Attach the Function in Ribbon Workbench: Use this function in a Display Rule or Enable Rule for the Edit button.
Publish and Test: After publishing the changes, test the behavior in your app to ensure the button visibility aligns with your criteria.
This setup gives you flexibility and control over UI behavior based on business logic.
Please verify if this helps you move forward.
Thanks and best regards,\ Daniele\ Note: This response was prepared with support from Copilot to ensure clarity and completeness.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 247
Tom_Gioielli 166 Super User 2025 Season 2
MVP-Daniyal Khaleel 164