I want to add a attribute (Person or Group) in List through coding, does any one know how to do it.
thanks
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI want to add a attribute (Person or Group) in List through coding, does any one know how to do it.
thanks
[Saboor's comment re-posted as an answer, with minor modifications]
SPSite site = SPContext.Current.Site;
using (SPWeb web = site.OpenWeb())
{
SPListCollection lists = web.Lists;
SPList list = lists['Guid for List'];
list.Fields.Add("people", SPFieldType.User, false);
list.Update();
}
Itm["AssignedTo"] = new SPFieldLookupValue(Vti, "");
here vti
is USserID or GroupID