Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

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

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
    meelamri 13,204 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
    Charles Abi Khirs 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans