Sample code to check if User is a member of a team C# CRM 2011/2013/2015
Views (1718)
Sharing sample code to check if a user belongs to a team or not
public static bool IsTeamMember(Guid teamID, Guid userID, IOrganizationService service)
{
QueryExpression query = new QueryExpression("team");
query.ColumnSet = new ColumnSet(true);
query.Criteria.AddCondition(new ConditionExpression("teamid", ConditionOperator.Equal, teamID));
LinkEntity link = query.AddLink("teammembership", "teamid", "teamid");
link.LinkCriteria.AddCondition(new ConditionExpression("systemuserid", ConditionOperator.Equal, userID));
var results = service.RetrieveMultiple(query);
if (results.Entities.Count > 0)
{
return true;
}
else
{
return false;
}
}
Hope it helps.
Filed under: CRM, CRM 2011, CRM 2013, CRM 2015, Microsoft Dynamics CRM Tagged: CRM 2011, CRM 2013, CRM 2015, Microsoft Dynamics CRM
This was originally posted here.

Like
Report
*This post is locked for comments