I am creating a list item using the code below:

var context = new SP.ClientContext.get_current(); 
var dfd = $.Deferred(); 
var targetList = context.get_web().get_lists().getByTitle(listName);
var itemCreateInfo = new SP.ListItemCreationInformation(); 
var listItem = targetList.addItem(itemCreateInfo);

listItem.set_item("Title", listValues[0].Title); 
listItem.set_item("Department", listValues[0].Department);  
listItem.set_item("TeamMembers", listValues[0].TeamMembers);
listItem.set_item("Notes", listValues[0].Notes);  
    function () { 
        var id = listItem.get_id();
        if (listValues[0].Files.length > 0) {   
             if (fileCountCheck <= listValues[0].Files.length - 1) {                 
                 loopFileUpload(listName, id, listValues, fileCountCheck).then( 
                 function () { }, 
                 function (sender, args) { 
                     dfd.reject(sender, args); 
                 } ); 
        else { dfd.resolve(fileCountCheck);             } 
    function (sender, args) {       }   ); 

TeamMembers is a string containing the UserIds of all the users selected in a people picker, in the format ;#564;#5454;#56;#865;#

It is working if only one person is selected. I noticed that when there are multiple users selected, many of them are not getting saved into the list.

What could be the issue?

  • 1
    Check this if it helps. Commented May 13, 2020 at 14:06
  • 1
    Thanks @GaneshSanap, that really helped.
    – entryton
    Commented May 13, 2020 at 14:36
  • Glad it worked for you. I have added it as an answer below with explanation and reference link. Please Upvote(^) and accept as an Answer as it helped you. Commented May 14, 2020 at 13:38

2 Answers 2


Thanks to the comment by @Ganesh Sanap, I changed the data passed into the user field as below:

TeamMembers now has a value in the format ";#" + this.user1.get_id() + ";#" + this.user1.get_loginName() + ";" + this.user2.get_id() + ";#" + this.user2.get_loginName().

With the latest format, I am able to successfully save all the usernames into the list.


Instead of passing only User IDs in TeamMembers, try passing the User ID as well as User Login name separated ;# (And multiple users separated by ;) like below:

var userField = this.user1.get_id() + ";#" + this.user1.get_loginName()+";"+this.user2.get_id() + ";#" + this.user2.get_loginName(); // and so on...
listItem.set_item('TeamMembers', userField);

Reference: Add multiple people using Javascript Client Object Model.

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.