Get username from SharePoint User field in List

前端 未结 2 1173
轻奢々
轻奢々 2021-02-06 18:35

I have a custom sharepoint workflow that I\'m developing in Visual Studio. The workflow is running against a document library which has a custom content type connected to it. Th

2条回答
  •  被撕碎了的回忆
    2021-02-06 19:10

    My solution:

    public static SPUser GetSPUser(SPListItem item, string key)   
    {
        SPUser user=null;   
        SPFieldUserValue userValue = new SPFieldUserValue(item.Web, item[key].ToString());
        if (userValue != null)
        {
            SPUser user = userValue.User;
        }
    return user;
    }
    

    How To Call:

    SPUser spUser=GetSPUser(splistItem,"Owner"); 
    

    This is tested code and working fine.

提交回复
热议问题