Okay this is in a way update to my previous post about SharePoint lookup column. This code example works well when you have column that is set to contain multiple user values.
(PeopleEditor pe; declared in the proper place and proper way)
ArrayList userLogins = pe.ResolvedEntities;
SPFieldUserValueCollection usersCollection = new SPFieldUserValueCollection();
foreach(PickerEntity userLogin in userLogins)
{
SPFieldUserValue valueToAdd = new SPFieldUserValue(SPContext.Current.Web, int.Parse(userLogin.EntityData[“SPUserID”].ToString()), userLogin.EntityData[“DisplayName”].ToString());
usersCollection.Add(valueToAdd);
}
//now we have a proper usersCollection with accounts that were given and validated in PeopleEditor
//and all what there is left is to save information as the SharePoint way which means userID;#DisplayName#;userID;# … which is quite painful if you try to make it only as a string modification
splistItem[“ColumnNameThatIsMultiUserColumn”] = usersCollection.ToString();
splistitem.Update();
Voilá a whole less painfull. I do not know if there is a way to get that SPFieldUserValueCollection directly from PeopleEditor, but for quick searching it seemed that things are not that simple. Feel free to comment if there is something more into this. And if needed I can create sample of adding these multiuservalues to PeopleEditor (which after creating this is more like walk in the park).
thank you so much for this post it really helped me!!
My brother recommended I may like this website. He was entirely
right. This publish actually made my day.
You can not imagine just how a lot time I had spent for this info!
Thank you!