web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

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

(0) ShareShare
ReportReport
Posted on by 97

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

I have the same question (0)
  • Suggested answer
    Henry J. Profile Picture
    5,237 on at

    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

  • AJ-22040756-0 Profile Picture
    on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 49 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans