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



Nov 9, 2012, 7:37 AM
21 Posts

FileUpload save attachment SSJS

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: attachment
  • Replies: 3
 Hi, 
 
anybody can help me with storing attachment using SSJS. 
 
I have a RichText field I named as 'AIF_Attachment'. 
 
I also have File Upload and File Download control which I named as 'FileUpload' and 'FileDownload' both bind to 'AIF Attachment'.
 
I have below SSJS which I execute when I click 'save' button to store the attachment :
 
===================================================================
var attachmentList:java.util.List=currentDocument.getAttachmentList("FileUpload") 
if(!attachmentList.isEmpty()){
var attachmentObject:NotesEmbeddedObject = attachmentList.get(0);
var rtItem:NotesRichTextItem=newDoc.createRichTextItem("AIF_Attachment");
rtItem.embedObject(attachmentObject.EMBED_ATTACHMENT, "", attachmentList, null);
rtItem.update();
====================================================================
 
This don't seem to work, please help, TQ. 
Nov 12, 2012, 11:13 AM
43 Posts
Re: FileUpload save attachment SSJS
 Hi,
 
When you have a submit button and "upload and download control" linked to the "same rich text" then it gets stored automatically.  You don't need any javascript. You might be getting redirected to a new page. Just select a default option in serverside javascript: "OpenPage" and pass the current documentID..  You should be able to see the uploaded documents..
Nov 12, 2012, 11:18 AM
43 Posts
Re: FileUpload save attachment SSJS
  Cont..
 
If you just want to store in a different document then you can use something like this: 
 
var doc:NotesDocument= currentDocument.getDocument(); // or document1.getDocument(); 
 
var item:NotesRichTextItem;
 
item=doc.getFirstItem("AIF_Attachment"); 
 
var doc2:NotesDocument= database.createDocument();
 
doc2.copyItem(item,"AIF_Attachment");
 
doc2.save(); 
 
Hope this helps..! 
Nov 14, 2012, 1:20 AM
21 Posts
Re: FileUpload save attachment SSJS
Thanks bro, 
 
By the way, I can attach using the 'save document' method but I'm using SSJS because I need to execute some other function when I save the form.
 
TQ. 

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