SPFieldUserValue Class
Contains the value for an SPFieldUser object.
Namespace:
Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Parsing With SPFieldUserValue With Extension Methods
When using SPFieldUserValue to hydrate properties like SPFieldUserValue.Login, it is best to use consistent extension methods as demonstrated below:
public static string GetUserLogin(this SPListItem item, string fieldName)
{
var userValue = new SPFieldUserValue(item.Web, (string) item[fieldName]);
return userValue.User != null ? userValue.User.LoginName : string.Empty;
}
Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com
- 10/12/2010
- Adam Buenz - MVP
- 10/12/2010
- Adam Buenz - MVP