我需要帮助,我的代码现在可以正常工作,但是存在一些问题,例如,我可以将记录插入SharePoint列表中,而在单行和选择字段中没有问题,但是对于多行选择字段我无法将数据存储在列表本身上,而是显示在视图上,但是当您尝试编辑项目时,数据没有存储在项目的窗体上。
这是我的代码:
function createListItem() {
var devName = document.getElementById("devName").value;
var gbsService = document.getElementById("gbsService").value;
var selectedValues = '';
$("#techUsed :Selected").each(function(){
selectedValues += $(this).val() + ",";
});
if(selectedValues.indexOf(',') > -1) {
selectedValues = selectedValues.slice(0, -1);
}
var clientContext = new SP.ClientContext('SP URL');
var oList = clientContext.get_web().get_lists().getByTitle('SP List Name');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', devName);
oListItem.set_item('Technology_x0020_Used', selectedValues);
oListItem.set_item('GBS_x0020_Service_x0020_Organiza', gbsService);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded() {
alert('Item created: ' + oListItem.get_id());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}