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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 98 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 72

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans