使用JSOM

时间:2016-07-26 04:58:20

标签: sharepoint sharepoint-2013 sharepoint-jsom

我正在创建一个锐化的托管应用。我是客户端人员选择器控件并尝试在Person / Group字段(Supervisor)中插入多个用户值并获取此错误“用户不存在或不是唯一的”。下面是我的代码,此代码适用于单个用户,并且对多个用户失败。任何人都可以帮忙..

var list = web.get_lists().getByTitle("StudentDetails");
var listCreationInformation = new SP.ListItemCreationInformation();
var listItem = list.addItem(listCreationInformation);
var peoplePicker =       ClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan;
  // Get information about all users.
  var users = peoplePicker.GetAllUserInfo();
   // Get user keys.
    var keys = peoplePicker.GetAllUserKeys();
   var finalusers = new Array();
   for (var i = 0; i < users.length; i++) {
  var arryuser = users[i];
     finalusers.push(SP.FieldUserValue.fromUser(arryuser.Key));
    }
   listItem.set_item("Supervisor", finalusers);
  listItem.update();
 ctx.load(listItem);

先谢谢

1 个答案:

答案 0 :(得分:0)

设置允许多项选择&#34;对于Supervisor列,为Yes。为我工作。解决方案在以下链接中提出。 http://www.c-sharpcorner.com/forums/insert-multiple-values-for-persongroup-field-using-jsom