Tuesday, September 11, 2012

Get user name form a peoplegroup column "Sharepoint 2010"



public List<string> getUserNameFromPeopleGroup(SPListItem ListItem, string PeopleGroup, SPWeb objWeb)
        {
            List<string> strLoginName = new List<string>();

            SPFieldUserValueCollection users = ListItem[PeopleGroup] as SPFieldUserValueCollection;
            if (users != null)
            {
                foreach (SPFieldUserValue userVal in users)
                {
                    if (userVal.User != null)
                    {
                        SPUser user = userVal.User;
                        strLoginName.Add(user.Name);

                    }
                }
            }
            return strLoginName;
        }

No comments:

Post a Comment