Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private SPFieldUserValueCollection GetPeopleFromPickerControl(PeopleEditor people, SPWeb web)
- {
- SPFieldUserValueCollection values = new SPFieldUserValueCollection();
- if (people.ResolvedEntities.Count > 0)
- {
- for (int i = 0; i < people.ResolvedEntities.Count; i++)
- {
- PickerEntity user = (PickerEntity)people.ResolvedEntities[i];
- switch ((string)user.EntityData["PrincipalType"])
- {
- case "User":
- SPUser webUser = web.EnsureUser(user.Key);
- SPFieldUserValue userValue = new SPFieldUserValue(web, webUser.ID, webUser.Name);
- values.Add(userValue);
- break;
- case "SharePointGroup":
- SPGroup siteGroup = web.SiteGroups[user.EntityData["AccountName"].ToString()];
- SPFieldUserValue groupValue = new SPFieldUserValue(web, siteGroup.ID, siteGroup.Name);
- values.Add(groupValue);
- break;
- }
- }
- }
- return values;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement