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 :
Customer experience | Sales, Customer Insights,...
Answered

How to iterate through the result of Xrm.Utility.getGlobalContext().userSettings.roles.getAll()?

(0) ShareShare
ReportReport
Posted on by 10

I am trying to iterate through the result of the Xrm.Utility.getGlobalContext().userSettings.roles.getAll() function but when stored in an array, it returns undefined. However when the function is run as is, it returns everything that I need. Can anyone help me out on this? This has been a roadblock to me for quite a few days now. I can't find anything that works from all the other answers I have found here.

pastedimage1628737888769v2.png

I have the same question (0)
  • Suggested answer
    Charan Raju C R Profile Picture
    7 Moderator on at

    Hi kthlnvrgna,

    If I am not wrong, the screenshot you provided is the watch from Developer Tools. forEach function wouldn't return the output in watch. You can either go to Console in Developer Tools to see the output or place the same javascript code in webresource by replacing console.log() with alert() so that, you can see the output in alert window.

    Watch output under Console:

    pastedimage1628740428891v2.png

    Javascript Code in webresource:

    pastedimage1628741004751v1.png

  • kthlnvrgna Profile Picture
    10 on at

    I am actually in testing on the Console of the Developer tools. And have already tried to simulate in the web resource, it really doesn't return anything. Am I doing something wrong?

    pastedimage1628824622529v1.png

    May I also ask why you had to have explicitly defined your object for the System Administrator in your forEach()?

  • kthlnvrgna Profile Picture
    10 on at

    Oddly it's working with alert(). Thanks for this.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans