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...
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

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
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans