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 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,218 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

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 107 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 94

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans