The code below is to get SPUser from a multiple user item column
string strURL = "http://YourSite/"; using (SPSite oSPSite = new SPSite(strURL)) { using (SPWeb oSPWeb = oSPSite.OpenWeb()) { SPList list = oSPWeb.GetList(strURL); SPListItemCollection items = list.Items; foreach (SPListItem oListItem in items) { if (oListItem["Title"].ToString() == "Test") { String usersString = oListItem["Audience Group"].ToString(); SPFieldUserValueCollection userValueColl = new SPFieldUserValueCollection(oSPWeb, usersString); foreach (SPFieldUserValue userValue in userValueColl) { SPUser siteUser = userValue.User; Console.WriteLine("User found: {0}", siteUser.Name); } break; } } }
No comments:
Post a Comment