Revision: 23058
Updated Code
at January 29, 2010 08:51 by dkitchen
Updated Code
public static SPUser GetUser(this SPListItem item, string displayName) { //get field and cast to User Field type var field = item.Fields.GetField(displayName) as SPFieldUser; if (null == field) { throw new ApplicationException("This field is not a User!"); } var fieldValue = field.GetFieldValue(item[field.Id].ToString()) as SPFieldUserValue; SPUser user = null; if (null != fieldValue) { user = fieldValue.User; } return user; }
Revision: 23057
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 28, 2010 19:56 by dkitchen
Initial Code
public static SPUser GetUser(this SPListItem item, string displayName) { //get field and cast to User Field type var field = item.Fields.GetField(displayName) as SPFieldUser; if (null == field) { throw new ApplicationException("This field is not a User!"); } var fieldValue = field.GetFieldValue(item[field.Id].ToString()) as SPFieldUserValue; if (null == fieldValue) { return null; } return fieldValue.User; }
Initial URL
Initial Description
Initial Title
Extension method to get SPUser object from SPListItem person field
Initial Tags
Initial Language
C#