Monday, October 17, 2011

Get User Login Name from SP User/Group Column in Sharepoint

SPFieldUser field = item.Fields["Approver"] as SPFieldUser;

if (field != null)
{
SPFieldUserValue fieldValue = field.GetFieldValue(item["Approver"].ToString()) as SPFieldUserValue;
if (fieldValue != null)
{
string str= fieldValue.User.LoginName;
}

}