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 retrieve security roles of a team using c#

(0) ShareShare
ReportReport
Posted on by 455

Hi Guys,

Our project now has a requirement that need to retrieve security roles for a team, but I didn't find a existing method of Microsoft to implement this function. Do you know how to retrieve all of security roles of a team using C#. Thanks a lot.

 

Thanks,

Stone

I have the same question (0)
  • Verified answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    You can use this fetchXml to retrieve security roles for a team.

      
        
          
            
            
          
        
      
    

    Similarly, with C# code using a Query Expression: 

    // Define Condition Values (YOUR TEAM ID) 
    var QErole_teamroles_teamid = "6b8ae021-c966-eb11-a812-000d3a3b6b72";
    // Instantiate QueryExpression QErole
    var QErole = new QueryExpression("role");
    // Add all columns to QErole.ColumnSet
    QErole.ColumnSet.AllColumns = true;
    // Add link-entity QErole_teamroles
    var QErole_teamroles = QErole.AddLink("teamroles", "roleid", "roleid");
    // Define filter QErole_teamroles.LinkCriteria
    QErole_teamroles.LinkCriteria.AddCondition("teamid", ConditionOperator.Equal, QErole_teamroles_teamid);
    
    
    var roles = service.RetrieveMultiple(QErole);
    foreach (var role in roles.Entities)  
    {  
        //Your Logic
    }  
      
     

  • Stone Huang Profile Picture
    455 on at

    Hi Amri,

    This is a good idea, thanks.

    Thanks,

    Stone

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 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans