Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Sales forum / Show/Hide Reactivate b...
Sales forum
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.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,353 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,251 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans