Announcements
Hi All
I want to get current user security roles with their names. I'm using Xrm.Utility.getGlobalContext().userSettings.roles.getAll() but unable to get roles and names.
I am not using Model Driven app (Unified Interface). I want to get user roles and names without HTTP Request. Can anyone help me please
Hi Partner,
If you can only get GUID and Xrm.Utility.getGlobalContext().userSettings.roles doesn't work, you may still need an extra HTTP request.
Here is sample of combination of Xrm.Utility.getGlobalContext().userSettings.securityroles and HTTP request:
Regards,
Clofly
I'm getting an error "undefined" on roles
but when i get roles through Xrm.Utility.getGlobalContext().userSettings.securityroles; I am getting only guid not names
I'm getting an error "undefined" on roles
but when i get roles through Xrm.Utility.getGlobalContext().userSettings.securityroles; I am getting only guid not names
Hi Partner,
You need to loop through the returned collection.
var roles = Xrm.Utility.getGlobalContext().userSettings.roles; roles.forEach(function (item) { console.log(item.name); });
I'm not sure whether Xrm.Utility.getGlobalContext().userSettings.roles has been deprecated in legacy web client, you may still need to add an extra HTTP request if the API doesn't work in old UI, because the old API to retrieve security roles only returns collection of GUID.
https://neilparkhurst.com/2016/08/03/crm2016-javascript-context-object/(See Getting GUID of User Roles section of the article.)
Regards,
Clofly
This article suggests you may have one too many var stuff = Xrm.Utility.getGlobalContext().userSettings.roles;
Hi All
I want to get current user security roles with their names. I'm using Xrm.Utility.getGlobalContext().userSettings.roles.getAll() but unable to get roles and names.
I am not using Model Driven app (Unified Interface). I want to get user roles and names without HTTP Request. Can anyone help me please
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,734 Super User 2024 Season 2
Martin Dráb 229,021 Most Valuable Professional
nmaenpaa 101,150