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);
context.load(targetList);
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);
listItem.update();
context.executeQueryAsync(
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?