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

(0) ShareShare
ReportReport
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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,187 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,966 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans