using(SPSite spSite = new SPSite("site URL")) { using(SPWeb spWeb = spSite.OpenWeb()) { SPList spList = spWeb.Lists["List Name"]; SPListItem spListItem = spList.GetItemByID(itemID); string currentValue = spListItem["Person or Group field name"].ToString(); SPFieldUser userField = (SPFieldUser)spWeb.Lists["List Name"].Fields.GetField("Person or Group field name"); SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(currentValue); SPUser user = fieldValue.User; OR SPFieldUserValue spFieldUserValue = new SPFieldUserValue(web , Convert.ToString(projectItem["Person or Group field name"])); SPUser user = spFieldUserValue.User; } }
Wednesday, May 5, 2010
SharePoint List’s Person or Group field value as c# SPUser objet
Casting the list's Person or Group field value into SPUser object.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment