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
Was this reply helpful?YesNo
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.