Skip to main content

Notifications

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

Show/Hide Reactivate buton on Case form based on user Role

Posted on by 4,084

I followed the exact steps in this link but the Reactivate button still showing on the Case Form.

Even I added an Alert line in the JS functon but does not seem to be detected.

Not sure what exactly missing?

How to Hide Buttons Based on User Security Role in Dynamics 365 Sales | Stoneridge Software

  • Suggested answer
    Alaa Ramadan Profile Picture
    Alaa Ramadan 4,084 on at
    RE: Show/Hide Reactivate buton on Case form based on user Role

    I beleive I found the issue.

    I was missing the step of attaching the new rule to the command.

    Thank you,

  • Alaa Ramadan Profile Picture
    Alaa Ramadan 4,084 on at
    RE: Show/Hide Reactivate buton on Case form based on user Role

    Thank you Steve, but is not it the same code in the link above. this is exactly what I'm using and is not working.

    I'm guessing this is not a code issue. it is something else can e related with the solution.

  • Suggested answer
    Steve Zhao2 Profile Picture
    Steve Zhao2 on at
    RE: Show/Hide Reactivate buton on Case form based on user Role

    Hi Alaa Ramadan,

    Please change code to this to have a try:

    //
    // Hide the Activate button and the Deactivate button when user has Salesperson security role
    //
    function hideActivateAndDeactivateRibbonButtons() {
    //
    // default return value to true. Show buttons
    //
    var value = true;
    //
    // Set variable with SalesPerson security role GUID
    //
    var constSalesPersonGuid = "74E3A3A3-E6F3-4B97-A045-A557B1660293";
    //
    // Get the Current User's Security Roles
    //
    // D365 v9
    var userRoles = Xrm.Utility.getGlobalContext().userSettings.securityRoles;
    //
    // loop through roles and look for SalesPerson guid
    //
    for (var i = 0; i < userRoles.length; i  ) {
    if (userRoles[i].toUpperCase() == constSalesPersonGuid.toUpperCase()) {
    //
    // Hide Activate button and the Deactivate button
    //
    value = false;
    break;
    }
    }
    return value;
    }

    And please make sure the enable rule is tied to the command.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans