Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Fetch Privileges from a security role obtained from javascript resultant array

Posted on by 72

Hello,

I was trying to hide a button based on security role.

I created javascript which checks and then hides button for "D365 FS Mobile Resource" security role.

hideButtonForFSMRole = function () {
    debugger;
    var showButtonFlag = true;
    var roles = Xrm.Utility.getGlobalContext().userSettings.roles;
    var role_name = new Array();
    roles.forEach(function (item) {
        role_name.push(item.name);
    });

    if(role_name.length>0){
        for(i=0;i

How do I hide button only when Create privileges of "D365 FS Mobile Resource" is set to none.

  • Suggested answer
    Charles Abi Khirs Profile Picture
    Charles Abi Khirs 3,569 on at
    RE: Fetch Privileges from a security role obtained from javascript resultant array

    Hello,

    As Bipin stated, it can be done from the Ribbon workbench provided in the link. And this will cover even if the user has multiple security roles, if one of the security roles has the Create privilege, than it will consider as the user has this privilege and do whatever you set in your display rule.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Fetch Privileges from a security role obtained from javascript resultant array

    Hi Mansi M,

    You could use RetrieveRolePrivilegesRole() function to get the privileges in a role.

    Reference:

    community.dynamics.com/.../how-to-retrieve-the-effective-privileges-of-a-user-which-includes-user-role-level-and-team-level-privileges

  • Mansi M Profile Picture
    Mansi M 72 on at
    RE: Fetch Privileges from a security role obtained from javascript resultant array

    Hello Bipin,

    This does provide the solution to some extent. But in my case single user has more than one security roles. How to overcome in this scenario.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Fetch Privileges from a security role obtained from javascript resultant array

    Hi,

    It can be achieved without writting any code.

    Please see below blog -

    goutamdascrm.wordpress.com/.../

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans