Retrieve crm users based on Team

If you are looking to get all crm users based on the teamid then this post is for you. You can use below code to retrieve users:

private EntityCollection GetAllTeamUsers(IOrganizationService _CrmService,Guid TeamID)
//Create query expression
QueryExpression _Query = new QueryExpression();
_Query.EntityName = “systemuser”;
_Query.ColumnSet = new ColumnSet(true);
_Query.LinkEntities.Add(new LinkEntity
LinkFromEntityName = “systemuser”,
LinkToEntityName = “teammembership”,
LinkFromAttributeName = “systemuserid”,
LinkToAttributeName = “systemuserid”,
LinkCriteria =
new FilterExpression
Conditions ={
new ConditionExpression(“teamid”,ConditionOperator.Equal,TeamID)
return _CrmService.RetrieveMultiple(_Query);

Enjoy !!!

Leave a comment

Filed under MS CRM 2011

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s