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 :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

List of all users and their teams

(0) ShareShare
ReportReport
Posted on by

Hello,

I want to to generate a list of all users along with their teams. Thing is my customer want a list of users with associated teams separated by a comma if the user is in more than one team. I am aware there isn't any OOB solution for this. But, is there any option in XrmToolBox to process this request?

Thank you 

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Harsha.D,

    As far as I know, there is no tool in XrmToolBox can do this. You have to write some code with SDK or Web API to achieve this.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    If you are familiar with Console Application C# code then you can copy paste below sample code to getlist of users with the teams -

    Dictionary userTeamLists = new Dictionary();
                    // Get List of Users
                    string userQuery = $@"
                                          
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                              
                                            
                                          
                                        ";
                    EntityCollection userEntities = crmSvc.RetrieveMultiple(new FetchExpression(userQuery));
                    foreach (var user in userEntities.Entities)
                    {
                        Guid userId = user.Id;
                        // Get List of Teams Associated to the user
                        string teamQuery = $@"
                                              
                                                
                                                
                                                
                                                
                                                
                                                
                                                  
                                                
                                                
                                                  
                                                    
                                                      
                                                    
                                                  
                                                
                                              
                                            ";
    
                        EntityCollection teamEntities = crmSvc.RetrieveMultiple(new FetchExpression(teamQuery));
                        StringBuilder teamNames = new StringBuilder();
                        foreach (var item in teamEntities.Entities)
                        {
                            string teamName = item.GetAttributeValue("name");
                            teamNames.Append(teamName);
                            teamNames.Append(",");
                        }
                        userTeamLists.Add(userId.ToString(), teamNames.ToString());
                    }

    If you want to export the list as cvs then you can easily convert dictionary objectto csv file.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 75 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 52 Super User 2025 Season 2

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 42 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans