Here is the code.
1. First example is to get the System Users in a Team
2. Second example is to get System Users as ActivityParty that you might need to link with an Activity.
public List<SystemUser> GetTeamUsers(string teamName) { return (from user in Context.CreateQuery<SystemUser>() join teamMembership in Context.CreateQuery<TeamMembership>() on user.SystemUserId.Value equals teamMembership.SystemUserId join team in Context.CreateQuery<Team>() on teamMembership.TeamId.Value equals team.TeamId.Value where team.Name == teamName select user ).ToList(); }
public List<ActivityParty> GetTeamUsersAsActivityParty(string teamName) { return (from user in Context.CreateQuery<SystemUser>() join teamMembership in Context.CreateQuery<TeamMembership>() on user.SystemUserId.Value equals teamMembership.SystemUserId join team in Context.CreateQuery<Team>() on teamMembership.TeamId.Value equals team.TeamId.Value where team.Name == teamName select new ActivityParty { PartyId = new EntityReference { LogicalName = user.LogicalName, Id = user.SystemUserId.Value } }).ToList(); }
No comments:
Post a Comment