web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How do i hide/show Edit button command based on a criteria

(4) ShareShare
ReportReport
Posted on by 38
Hi All,
I'm new to this and have a model driven app i need to customise.
I would like to disable the Edit command bar if the  user is in a specific user role (Dataverse Teams and a role assigned to it) and the field status is marked as complete.

When i tried opened the edit button  in using the power apps designer it was all greyed out and marked a read only.
I think my option is to use javascript and webresources.
I also noticed alot of people are talking about using Ribbon Workbench but not sure if i can use such logic in it

To have a javascript do this where would be best way to start e.g looking for the right function to call to get the roles to compare or how to see the field names

Thanks in advance
I have the same question (0)
  • Suggested answer
    DAnny3211 Profile Picture
    11,417 Super User 2026 Season 1 on at

    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:

     

    1. Use Ribbon Workbench: This tool allows you to customize command bar buttons. You can define display rules and enable rules based on JavaScript functions.


    2. Create a JavaScript Web Resource: Write a function that checks:

       

      • If the current user has a specific security role.

      • If the field status is marked as complete.
       

      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");
      }
      

       


    3. Attach the Function in Ribbon Workbench: Use this function in a Display Rule or Enable Rule for the Edit button.


    4. Publish and Test: After publishing the changes, test the behavior in your app to ensure the button visibility aligns with your criteria.



    5.  
     

    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.

  • Suggested answer
    Tom_Gioielli Profile Picture
    3,084 Super User 2026 Season 1 on at
    While you can use Ribbon Workbench and Javascript, that might even be overkill for what you are looking to do.
     
    Dataverse records typically have two states, 'Active' and 'Inactive'. These states have the benefit of altering whether a record can be edited as default behavior. When a record gets marked as Inactive, it becomes read-only for all users. The only way to edit it again is to "reactivate" the record.
     
    Can you track your complete status as a [Status Reason] option of the 'Inactive' state? If so, then when the record is Completed that means it is also inactive, and the entire record will be read only without any need to mess with JS or the Ribbon Workbench.
     
    If you really want to customize the ribbon, which I usually try to avoid unless necessary, then you would need to create a copy of the Default 'Edit' button, customize that one, and hide the original.
  • naijacoder Profile Picture
    38 on at
    Thanks Tom for your response.
    I like the idea of keeping it very simple but if i don't use RWB and use Power App studio to edit the Edit button command it says the button is read only.Legacy button is not supported
     
    Also the context menu of the Edit is grayed out. I only sre paste
     


    Maybe i'm missing something.
    Can you please advice?
     
  • Suggested answer
    Inogic Profile Picture
    748 on at
    Hi,
     
    Since these are legacy buttons, they can only be customized using the Ribbon Workbench in XrmToolBox. Both XrmToolBox and the Ribbon Workbench solution are free tools. Within Ribbon Workbench, you can add JavaScript web resources to define custom enable/display rules that will show or hide the button based on your logic.
     
    Hope this helps.
     
    Thanks!
    Inogic

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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 196 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans