Skip to main content

Notifications

Announcements

No record found.

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

context.userSettings.securityRoles OR Xrm.Page.context.getUserRoles() not working properly

Posted on by 95

Hello Experts,

I have given only the System Admin Security Role to the user. We have some custom Security Roles as well in the system.

what is weird thing is happening that when I retrieved the Security Roles using Javascript Code using context.userSettings.securityRoles OR Xrm.Page.context.getUserRoles() this method 

then it is returning 2 extra Security Roles which user does not have. This is happening on Client Sandbox Org from yesterday. Also, these extra 2 Roles returning for All users. I have tried Checked/Unchecked Security Roles, Even then it is returning extra Roles. These 2 Extra Security Roles are static for all while calling JS method to getting Security Roles.

But I have checked the same JS code on my development org. It is returning proper Roles. Working properly on Development Org.

Thanks in Advance

Shrikant

  • RE: context.userSettings.securityRoles OR Xrm.Page.context.getUserRoles() not working properly

    Hi Partner,

    As rightly said by Henry,  Please check for the roles assigned to the Business Unit or Teams for which the users are a part of as the context.userSettings.securityRoles  will pull all the security roles assigned to Teams for which a user is part of.

  • Suggested answer
    Henry J. Profile Picture
    Henry J. 5,237 on at
    RE: context.userSettings.securityRoles OR Xrm.Page.context.getUserRoles() not working properly

    Hi Shrikant,

    First, I wouldn't use Xrm.Page.context.getUserRoles as it has officially been deprecated.

    Xrm.Utility.getGlobalContext().userSettings returns the security roles assigned directly to your users but also the roles that the user has inherited through a team membership.
    Have you checked the teams your user belongs to?

    If all users have that role, it is likely that it's been assigned to the business units default teams.

    Henry

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans