I have a notes document that has two attachments. attachFile and attachFile_1. After I upload an pdf to attachFile_1 I want to delete that item if it fails a manual verification by the user. I have it such that the item does delete but the document still retains the $FILE property when I open the document properties.
See code below.
Xpages Code
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:script src="/scriptsFile.jss" clientSide="false"></xp:script>
</xp:this.resources>
<xp:panel id="pnlDocData">
<xp:this.data>
<xp:dominoDocument var="document1" formName="frmA" action="openDocument"
documentId="#{javascript:sessionScope.id}" scope="request">
</xp:dominoDocument>
<xp:table style="width:99%">
<xp:tr>
<xp:td align="center" valign="middle">
<xp:label id="label1" value="Verify Client Submission"></xp:label>
</xp:td>
<xp:td>
<xp:fileDownload rows="30" id="fileDownload1" displayLastModified="false" value="#{document1.attachFile_1}">
</xp:fileDownload>
</xp:td>
<xp:td>
<xp:button value="Decline" id="button">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete" id="eventHandler7">
<xp:this.action><![CDATA[#{javascript:decline()}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
</xp:view>
Javascript File
function decline()
{
var doc:NotesDocument = document1.getDocument();
doc.replaceItemValue("attachFile_1", null);
var item:NotesItem = doc.getFirstItem("attachFile_1");
item.remove();
doc.save();
}
When I run the code below I'm still getting an attachment size of 2 when I should get a size of 1.
var doc:NotesDocument = database.getDocumentByUNID(sessionScope.id);
var attachments:java.util.Vector = session.evaluate("@AttachmentNames", doc);
print(attachments.size());