嗨,这在单击按钮时效果很好;它循环视图中的选定项目,提醒 id 并调用 updateListItem 函数
function ViewSelectedItems(){
var selectedItems = SP.ListOperation.Selection.getSelectedItems();for (var i = 0; i < selectedItems.length; i++) { alert("Item with Id = " + selectedItems[i].id+ " is selected"); updateListItem(selectedItems[i].id)}
window.location.href = window.location.href;
}
updateListItem 报告 onQuerySucceeded 但字段值未设置为新值。请问有什么想法吗?
function updateListItem(passedid) {
var siteUrl = '/supportdepts/hr/';
var newval = 999;
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Staffing Control Panel Request');
this.oListItem = oList.getItemById(passedid);
oListItem.set_item("RefNumber", newval);
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
alert('Item updated!');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}