Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
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,962 Moderator 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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 228,651 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans