I'm trying to get SystemUser
info from TeamMembership
. I've been trying with these snippets but the first one, create a new entity, but don't retrieve all info of the user, like email address, phone number etc...
foreach (TeamMembership user in teamMembers)
{
sysUser.Id = user.SystemUserId.Value;
if (sysUser.InternalEMailAddress != string.Empty)
{
ActivityParty toParty = new ActivityParty();
toParty.PartyId = new EntityReference(SystemUser.EntityLogicalName, user.SystemUserId.Value);
toPartyList.Add(toParty);
}
}
Then I've tried with this one, but it doesn't return anything!
// Get the Team Entity from the Workflow input parameter
Guid team = TeamName.Get<EntityReference>(executionContext).Id;
List<SystemUser> users =
(from user in datacontext.CreateQuery<SystemUser>()
join teamMembership in datacontext.CreateQuery<TeamMembership>()
on user.SystemUserId.Value equals teamMembership.SystemUserId
join thisteam in datacontext.CreateQuery<Team>() on teamMembership.TeamId.Value equals thisteam.TeamId.Value
where thisteam.Name == TeamName.Get<EntityReference>(executionContext).Name
select user).ToList();
foreach(SystemUser user in users)
{
if (user.InternalEMailAddress != null)
LoggerObj.WriteLog("User " + user.FirstName + " Email:" + user.InternalEMailAddress);
}
I haven't run your code for technical reasons (read: I'm a bit lazy) but it occurs to me that you should relax the conditions in your LINQ statement. Then, once you get in any SystemUser instance(s), you can tighten it up again. And if you don't get anything even after the full relaxation, you got an other problem. :)