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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to get record owner's security role with JavaScript?

(0) ShareShare
ReportReport
Posted on by
Hello,
 
The current user's can be retrieved easily, but how can I get the record owner (also a CRM user) role with JS code?
 
Thanks.
  • Verified answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    You can use the following code to get the security roles of the record owner.
     
    Xrm.WebApi.retrieveMultipleRecords("systemuser", "?$filter=fullname eq '<CRM User Name>'&$select=fullname&$expand=systemuserroles_association($select=name)").then(
        function success(result) {
            var securityRoles = result.entities[0].systemuserroles_association;
            for (var i = 0; i < securityRoles.length; i++) {
                console.log(securityRoles[i].name);
            }  
           
        },
        function (error) {
            console.log(error.message);
        }
    );
     
    In my testing, I was the System Administrator, and the owner of the records was me.
    The security roles I get using the code provided above are the same as the officially provided API: Xrm.Utility.getGlobalContext().userSettings.roles.
     
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me .
     
    Best Regards,
    Dengliang Li
     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
ParthPatel249 Profile Picture

ParthPatel249 64

#2
11manish Profile Picture

11manish 52 Super User 2026 Season 2

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 44 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans