Click here to Skip to main content
15,891,745 members
Articles / Programming Languages / Javascript
Tip/Trick

How to Add/Update SharePoint User Field (Person Group Column) using ECMA Scripts

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
30 Sep 2014CPOL 28.2K   1  
How to add/update SharePoint User Field (Person group column) using ECMA scripts

Introduction

SharePoint app model supports enough capability to work with SharePoint from JavaScript.

Working with Person Group column is a common task in SharePoint development. The 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 to the person or group by ID.

JavaScript
// this is the ID for User or Group in SharePoint
listitem.set_item("Column Name", user);
ctx.ExecuteQuery();

Insert / Update Multi Value SharePoint Person Group Column (People Field)

Tip: For multiple users, you need to refer to it by login name.

JavaScript
"i:0#.f|membership|melick@oapp.onmicrosoft.com")); // adding user 
ctx.ExecuteQuery();

*listitem: This is the list item you need to manipulate. If you are inserting an item, this will be created using ListItemCreationInfo and if you are updating an item, this will be a reference to the item you seek.

Reference

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Sri Lanka Sri Lanka
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --