I have a list with a multiple people column (name it Members).
I want to update item's column to add a user to it. But it have to keep all users already in the item's column. I want to do so using JavaScript.

So far, I have :

function addUser() {

    var clientContext = new SP.ClientContext(siteUrl);
    var list = clientContext.get_web().get_lists().getByTitle('MyList');
    var listItem= list.getItemById(listItemID);

    var newMembers = oldMembers + newUser; 

    clientContext.executeQueryAsync(console.log("ok."), console.log("ko."));

newUser contains id and loginName like: 1#;i:0#.f|membership|[email protected]
In oldUser, i would like to have all user already in the field. To do so, i wanted to use this:

var oldMembers = listItem.get_item("Members");

But I keep having this error:

Uncaught Error: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

Is there another way to add my new user at the end of my old users list?

Environment : SharePoint Online. I'm working on a display template for a search web part only for this list. Users should be able in one click to join an item.

2 Answers 2


It is not clear where in code you are executing this line:

var oldMembers = listItem.get_item("Members");

You should try to call the load function before that line:

clientContext.load(listItem, 'Include(Members)');

EDIT: You should also load the list after creating the list variable:

var list = clientContext.get_web().get_lists().getByTitle('MyList');
  • I was executing it just after getting listItem.
    – S61ze
    Commented Feb 7, 2017 at 14:47
  • I tried but it did'nt work either.
    – S61ze
    Commented Feb 7, 2017 at 14:51
  • Please see my updated answer. Commented Feb 7, 2017 at 15:48

I managed to solve my problem using REST API.

First : Use Get to know whose users are already in the Members field

    url: siteDirectoryUrl + "/_api/web/lists/getbytitle('" + listName + "')/items?$filter=Title eq '" + title + "'",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {

        //Action here
    error: function (error) {
        console.log("second here: " + JSON.stringify(error));

Second : Put the information in an array

var object = data.d.results;
var array = object[0].MembersId;

Third: Add current user to the array

array = object[0].MembersId.results;

var dataInfos = {
    __metadata: {"type": "SP.Data.MyListListItem"},
    MembersId:{"results": array}

Fourth : Use Patch to update the Members field with the new user.

    url: siteDirectoryUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(" + listItemID + ")",
    headers: {
        "accept": "application/json;odata=verbose",
        "content-Type": "application/json;odata=verbose",
        "X-Http-Method": "PATCH",
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
        "If-Match": "*"

    success: function (data) {},
    error: function (error) {

I did it to remove user too. Feel free to ask me for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.