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.
I have the same question (0)
  • 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
11manish Profile Picture

11manish 156

#2
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans