I am currently trying to retirve all the users from a user field with multiple selection in an event handler….I did the the following but nothing seems to be happening…Can you please give me some advice?
I think the problem is in the first line but not too sure.
Hi,
I am currently trying to retirve all the users from a user field with multiple selection in an event handler….I did the the following but nothing seems to be happening…Can you please give me some advice?
I think the problem is in the first line but not too sure.
SPUserCollection userVals = (SPUserCollection)properties.AfterProperties["Team_x0020_Leader"];
foreach (SPUser userVal in userVals)
{
string TLeaderName = userVal.Name.ToString();
string TLeaderEmail = userVal.Email.ToString();
string TLeaderLogin = userVal.LoginName.ToString();
SPRoleAssignment roleAssignment1 = new SPRoleAssignment(TLeaderLogin, TLeaderEmail, TLeaderName, “notes”);
SPRoleDefinition RoleDefinition1 = newWeb.RoleDefinitions.GetByType(SPRoleType.Administrator);
roleAssignment1.RoleDefinitionBindings.Add(RoleDefinition1);
//Check inheritance for Project Manager
if (!newSubWeb.HasUniqueRoleAssignments)
{
newSubWeb.BreakRoleInheritance(true);
}
newSubWeb.RoleAssignments.Add(roleAssignment1);
}
Thank you
Kind regards
Chris Sammut
When you debug is the collection “userVals” filled up?