Created
July 23, 2013 14:04
-
-
Save RyanHirsch/6062604 to your computer and use it in GitHub Desktop.
Get SPUser Object from ListObject by key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static SPUser GetSPUser(SPListItem item, string key) | |
{ | |
SPFieldUser field = item.Fields[key] as SPFieldUser; | |
if (field != null && item[key] != null) | |
{ | |
SPFieldUserValue fieldValue = field.GetFieldValue(item[key].ToString()) as SPFieldUserValue; | |
if (fieldValue != null) | |
{ | |
return fieldValue.User; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment