Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

I have two buttons on ribbon of my form.i want these buttons to appear only to particular set of users,

Posted on by Microsoft Employee

I have two buttons on ribbon of my form.i want these buttons   to appear only to particular set of users,can anyone please help me to achieve this .

*This post is locked for comments

  • Suggested answer
    Michel Gueli Profile Picture
    Michel Gueli 982 on at
    RE: I have two buttons on ribbon of my form.i want these buttons to appear only to particular set of users,

    Radu,

    Your solution with a custom entity is to heavy for just showing and hiding a button. I would recommend a display/enable rule for this.

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: I have two buttons on ribbon of my form.i want these buttons to appear only to particular set of users,

    Hi Sandesh,

    You can enable / disable the buttons based on a privilege : social.microsoft.com/.../hide-ribbon-button-based-on-users-privilege-on-a-specific-record

    For example you create a custom entity and grant read access over it only to certain users (via a custom security role) and then have that button visible only for the users who have read privilege over that entity)

    Regards,

    Radu

  • shivaram Profile Picture
    shivaram 3,315 on at
    RE: I have two buttons on ribbon of my form.i want these buttons to appear only to particular set of users,

    Hi,

    Yes you can achieve using enable rule. First retrieve the role of an user and based on his role you can return true or false.

    function CheckUserRole() {

       var currentUserRoles = Xrm.Page.context.getUserRoles();

       var userRoleName = new String();

       for (var i = 0; i < currentUserRoles.length; i++) {

           var userRoleId = currentUserRoles[i];

           userRoleName += GetRoleName(userRoleId) + ",";

       }

       return userRoleName;

    }

    function includes(container, value) {

       var returnValue = false;

       var pos = container.indexOf(value);

       if (pos >= 0) {

           returnValue = true;

       }

       return returnValue;

    }

    function Enablerule(){

    var roleNameofCurrentUser = CheckUserRole().replace(",", "");

    if ((includes(roleNameofCurrentUser, "your role name[To whom you wanna show]"))

    return true;

    else return false;

    }

    Note: Here I mentioned include function also because default JS include will not work in IE few version.

    After completion of your JS now go to your button and add enable rule. And enter your function name and Library name.

    After that it will work fine.

  • Suggested answer
    Preeti Sharma Profile Picture
    Preeti Sharma 2,678 on at
    RE: I have two buttons on ribbon of my form.i want these buttons to appear only to particular set of users,

    Hi,

    You need to achieve this using enable and disable rules based on security roles.Following links may be helpful to you:

    community.dynamics.com/.../how-to-disable-a-crm-2016-ribbon-button-based-on-form-name

    garethtuckercrm.com/.../dynamically-disable-ribbon-buttons-in-dynamics-crm

    Thanks:)

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: I have two buttons on ribbon of my form.i want these buttons to appear only to particular set of users,

    Hi Sandesh,

    you can control it through security roles of the user , please use ribbon workbench.

    ribbonworkbench.uservoice.com/.../76681-hide-a-standard-out-of-the-box-button-based-on-a

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