繁体   English   中英

使用 JavaScript 更改 SharePoint 列上的下拉选择值

[英]Change drop-down choice value on SharePoint column using JavaScript

我已被分配从弹出窗口工作(从 Sharepoint 页面/“仪表板”上的按钮激活)window 从 SharePoint 列表打开一个新表单。 这就是弹出窗口的样子。

SharePoint 事件 XYZ 的新表格

注意:Promo Item、Quantity Purchased、Event、Delete(标志!!! )都是使用SharePoint新表格修改的。 这些输入都在 SharePoint 列表中各自的列中(从另一个角度来看)。 保存项目时,会发生这种情况:

为事件 XYZ 保存的玩具

注意:当 SAVE 后保存/创建玩具项目时,它会保存到另一个 SharePoint 列表以保存记录。

现在,请注意删除按钮。 创建玩具项目时,Delete 标志默认为 NO。 目标:我想单击删除按钮并将 Sharepoint 选择值从 NO 更改为 YES。 到目前为止,我已经创建了这段代码(它不起作用):

function deleteGuestName(parent, parentID){
    var clientContext = new SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('Toy Order List'); //SP list name 

        this.oListItem = oList.getItemById(listID); 
        this.oListItem = oList.set_item("Delete","Yes"); //I thought this would change the choice field
        oList.update();
        oListItem.deleteObject();

        clientContext.executeQueryAsync(
            Function.createDelegate(this, this.onQuerySucceeded),
            Function.createDelegate(this, this.onQueryFailed)
        )
}

function onQuerySucceeded() {
refreshGrid();
    parent.closeHSPopup();
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() +
                '\n' + args.get_stackTrace());
}

对此的任何帮助表示赞赏。 如果需要,我很乐意澄清。 thnxx

以下是您对代码的疑问。

this.oListItem = oList.getItemById(listID); 

要获取列表项, oList.getItemById(listID)应该是oList.getItemById(itemid)

要更新列表项, oList.update()应该是

this.oListItem.set_item("Delete","Yes")
this.oListItem.update()

如果要更新项目,为什么要调用oListItem.deleteObject()来删除项目?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM