web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Sample code to check if User is a member of a team C# CRM 2011/2013/2015

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee

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.

Comments

*This post is locked for comments