SharePoint In Action

An attempt to share my day-to-day SharePoint experience

Archive for the month “June, 2012”

Converting Person/Group Field to SPUser


I was trying to work with Person/Group field in SharePoint and I needed to convert it to SPUser in order to work with it in back-end.  I passed the list item and column name to this method:

public SPUser GetSPUserFromItem(SPListItem item, string fieldName)
     SPFieldUser spfu = (SPFieldUser)item.Fields[fieldName];
     SPFieldUserValue user = (SPFieldUserValue)spfu.GetFieldValue(item[fieldName].ToString());
     return user.User;

Nader Heshmat


Post Navigation