As we know that CRM Sdk deprecated RetrieveMembersTeamRequestmessage (https://msdn.microsoft.com/en-us/library/gg309360.aspx). So there is only way to retrieve Team Members using RetrieveMultipleRequest. and here is the method for the same. It works for the AccessTeam too.
private static void RetrieveTeamMembers(IOrganizationService service, EntityReference teamEntityReference)
{
QueryExpression userQuery = new QueryExpression("systemuser");
userQuery.ColumnSet = new ColumnSet("fullname");
LinkEntity teamLink = new LinkEntity("systemuser", "teammembership", "systemuserid", "systemuserid", JoinOperator.Inner);
ConditionExpression teamCondition = new ConditionExpression("teamid", ConditionOperator.Equal, teamEntityReference.Id);
teamLink.LinkCriteria.AddCondition(teamCondition);
userQuery.LinkEntities.Add(teamLink);
EntityCollection retrievedUsers = service.RetrieveMultiple(userQuery);
foreach (Entity user in retrievedUsers.Entities)
{
Console.WriteLine(String.Format("User: {0} with GUID {1}", user.GetAttributeValue<string>("fullname"),
user.Id));
}
}
No comments:
Post a Comment