SharePoint app model supports enough capability to work with SharePoint from JavaScript.
Working with Person Group column is a common task in SharePoint development. Following illustrates how to update a single and multiple values to SharePoint person group column.
Insert / Update Single Value SharePoint Person Group Column (People Field)
Tip: For single value you should refer the person or group by ID
var user = new SP.FieldUserValue();
user = 1; // this is the ID for User or Group in SharePoint
listitem.set_item("Column Name", user);
listitem.Update();
ctx.ExecuteQuery();
Insert / Update Multi Value SharePoint Person Group Column (People Field)
Tip: For multiple users you need to refer it by login name
var users =[];
users.push(SP.FieldUserValue.fromUser("dev Members")); // adding group
users.push(SP.FieldUserValue.fromUser("i:0#.f|membership|melick@oapp.onmicrosoft.com")); // adding user
listitem.set_item("Column Name", users);
listitem.Update();
ctx.ExecuteQuery();
*listitem this is the list item you need to manipulate. If you are inserting a item this will be created using ListItemCreationInfo and if you are updating a item this will be a reference to the item you seek
Ref: http://msdn.microsoft.com/en-us/library/office/hh185011(v=office.14).aspx
Comments