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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to show and hide custom button as per security role and status in ms crm 365

(0) ShareShare
ReportReport
Posted on by 95

I have a scenario in which custom button should be hide and show as per security role and status reason. 

I have the same question (0)
  • Suggested answer
    Charles Abi Khirs Profile Picture
    3,569 on at

    Hello,

    Check the below links:

    1. Show/Hide button based on security role (applied for system and custom buttons): www.powerobjects.com/.../

    2. Show/Hide button based on status reason: community.dynamics.com/.../358240

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hello,

    Yes, you can handle this scenario with a custom rule using JavaScript !

    function IsUserHasRoles() {
        // GUID of role to check
        var roleId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
        // Get all the roles of the Logged in User.
        var currentUserRoles = Xrm.Utility.getGlobalContext().userSettings.securityRoles;
        for (var i = 0; i < currentUserRoles.length; i  ) {
            var userRoleId = currentUserRoles[i];
            if (userRoleId == roleId) {
                // Return true if the Role matches
                return true;
            }
        }
        return false;
    }
    
    

    Mehdi,

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans