This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jul 22, 2011, 7:27 AM
261 Posts

Re: File Upload Control - Replace uploaded file instead of appending it

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: File Upload Control
  • Replies: 2
Daniel,
 
The way I solved this is by adding some code to the querySaveDocument event that checks if a new file was uploaded to a specific RichText Item and removes the existing one if needed.
 
Mark
 
Sample SSJS code in the querySaveDocument event :
 
//check if a new file was uploaded and if one already existed (and replace the existing one)
var RTITEM = "logo";
var strExistingFileName = null;
var newFileUploaded = false;
            
var attachments = currentDocument.getAttachmentList(RTITEM);
var it = attachments.iterator();
            
while( it.hasNext() ) {
 var att = it.next();
                
 if (att.getState().equals(com.ibm.xsp.model.domino.wrapped.DominoDocument$AttachmentValueHolder.STATE_ADDED) ) {
  newFileUploaded = true;
 } else if (att.getState().equals(com.ibm.xsp.model.domino.wrapped.DominoDocument$AttachmentValueHolder.STATE_INDOCUMENT) ) {
  strExistingFileName = att.getName();        
 }
            
}
            
if (newFileUploaded && strExistingFileName != null) {
 var att = currentDocument.getDocument().getAttachment(strFileToRemove);
 att.remove();
}
Jul 25, 2011, 9:44 PM
7 Posts
Re: File Upload Control - Replace uploaded file instead of appending it
 Hi Mark,
 
Thanks for your response. I finally did something similar removing the existing attachments before adding the new one by putting some code in the onClick event of the File Upload control. 
 
Daniel, 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal