1

The QueryDocumentDelete in Database script only seems to run from the Notes UI client when a document is deleted. Is there a similar event when a document is deleted with the Delete Selected Documents simple action?

4

1 回答 1

0

没错,数据库脚本中的 QueryDocumentDelete 是一个 Notes UI 函数,只能从 Notes 客户端运行。

不幸的是,在 simple action 中没有类似的事件Delete Selected Documents

一个简单的解决方法是自己编写“删除选定文档”的全部功能。通过这种方式,您可以在文档被实际删除或阻止某些文档被删除之前做您想做的事情。

以下是“删除所选文档”按钮的示例代码,该按钮可删除视图面板中的文档(ID 为“viewPanel1”):

<xp:button
    value="Delete Selected Documents"
    id="button1">
    <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="complete">
        <xp:this.script><![CDATA[
        if(!XSP.isViewPanelRowSelected("#{id:viewPanel1}", "_colcbox")){
            XSP.alert("Please select one or more documents to delete.");
            return false;
        }
        if (!XSP.confirm('Are you sure you want to delete selected documents?')){
             return false;
        }]]></xp:this.script>
        <xp:this.action><![CDATA[#{javascript:
        var viewPanel = getComponent("viewPanel1");
        var selectedIds = viewPanel.getSelectedIds();
        for(i=0; i < selectedIds.length; i++) {
            var docId = selectedIds[i];
            var doc = database.getDocumentByID(docId);
            // do things here you would do on QueryDocumentDelete
            doc.remove(true);
            doc.recycle();
        }}]]></xp:this.action>
    </xp:eventHandler>
</xp:button>
于 2013-10-27T21:12:10.140 回答