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. 

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at
    RE: How to show and hide custom button as per security role and status in ms crm 365

    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,

  • Suggested answer
    Charles Abi Khirs Profile Picture
    3,569 on at
    RE: How to show and hide custom button as per security role and status in ms crm 365

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 78 Super User 2025 Season 1

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 72

Overall leaderboard

Product updates

Dynamics 365 release plans