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



Apr 11, 2011, 1:37 PM
178 Posts

attachment names in a repeat control

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: attachments,$file,uploads
  • Replies: 4
I would like to display icons for the type of attachments are added to a document. I display the documents via a repeat control. I wonder what function I should use to get hold of the list of attachments since @AttachmentNames() does not seem to work. I tried getAttachmentList() but this dropped an error.

I tried

var objects:java.util.Vector = item.getEmbeddedObjects();

but this works fine when documents are attached via the Notes client not via a web browser.

So in case you can direct me to the proper method... much appreciated


Apr 11, 2011, 1:43 PM
21 Posts
Re: attachment names in a repeat control
Instead of item.getEmbeddedObjects(), try doc.getEmbeddedObjects(). 
Apr 12, 2011, 6:41 AM
178 Posts
Re: attachment names in a repeat control
Taken from the App Dev Wiki http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesDocument_sample_JavaScript_code_for_XPages:
 
=================================================
var entry:NotesViewEntry = colAuthor;
var doc:NotesDocument = entry.getDocument();

if (doc.hasEmbedded()) {
    var eos:java.util.Vector = doc.getEmbeddedObjects();
    if (eos.isEmpty()) {
        return "Contains attachments"
    } else {
        var msg:string = "Contains embedded objects:";
        var eosi:java.util.Iterator = eos.iterator();
        while (eosi.hasNext()) {
            var eo:NotesEmbeddedObject = eosi.next();
            if (msg.endsWith(":")) {
                msg = msg + " ";
            } else {
                msg = msg + "; ";
            }
            msg = msg + eo.getName();
        }
    return msg;
    }
} else {
    return "No embedded documents"
}
 
=======================

This will result for documents with attachments:

"Contains attachments"
 
I rather would like to get a list of attachment files ???

=======================

getAttachmentList() http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesXSPDocument_sample_JavaScript_code_for_XPages#getAttachmentList gives a runtime error: Error calling method 'getAttachmentList(string)' on an object of type 'lotus.domino.local.Document
 
=======================

Here is the code I am working on:
 
var entry:NotesViewEntry = colAuthor;
var doc:NotesDocument = entry.getDocument();

if(doc != null){
if (doc.hasEmbedded()){
    try {
        //var item:NotesRichTextItem = doc.getFirstItem("Rt_Body");
        var objects:java.util.Vector = doc.getEmbeddedObjects();
   
        if (!objects.isEmpty()){
            var o:NotesEmbeddedObject = objects.get(0);
   
            var fileType = o.getName().substr((o.getName().lastIndexOf(".")+1), o.getName().length);
           
            if("xls".equalsIgnoreCase(fileType)){
                return "Excel.jpg";
            }else if ("pdf".equalsIgnoreCase(fileType)){
                return "Pdf.jpg";
            }else if("doc".equalsIgnoreCase(fileType)){
                return "Word.jpg";
            }else if("ppt".equalsIgnoreCase(fileType)){
                return "PowerPoint.jpg";
            }else if("rar".equalsIgnoreCase(fileType)){
                return "WinRar.jpg";
            }else if("zip".equalsIgnoreCase(fileType)){
                return "Zip.jpg";
            }else if("avi".equalsIgnoreCase(fileType)){
                return "Movie.jpg";
            }else if("mp4".equalsIgnoreCase(fileType)){
                return "Movie.jpg";
            }else if("mpeg".equalsIgnoreCase(fileType)){
                return "Movie.jpg";
            }else if("wm".equalsIgnoreCase(fileType)){
                return "Movie.jpg";
            }else if("wmv".equalsIgnoreCase(fileType)){
                return "Movie.jpg";
            }else if("odp".equalsIgnoreCase(fileType)){
                return "SymphonyPresentation.jpg";
            }else if("otp".equalsIgnoreCase(fileType)){
                return "SymphonyPresentation.jpg";
            }else if("odt".equalsIgnoreCase(fileType)){
                return "SymphonyDocument.jpg";
            }else if("ott".equalsIgnoreCase(fileType)){
                return "SymphonyDocument.jpg";
            }else if("ods".equalsIgnoreCase(fileType)){
                return "SymphonySpreadsheet.jpg";
            }else if("ots".equalsIgnoreCase(fileType)){
                return "SymphonySpreadsheet.jpg";
            }else{
                return "MiscDocument.jpg";
            }
        } else {
            return "LotusNotes.jpg";
        }
    } catch(e) {
        return "LotusNotes.jpg";
    }
} else {
    return "LotusNotes.jpg";
}
}
 
(works fine in LS)
Apr 12, 2011, 8:04 AM
261 Posts
Re: attachment names in a repeat control
Patrick,
 
Have you tried this:

var attachments = session.evaluate( "@AttachmentNames", doc );
 
 
 
Apr 12, 2011, 11:18 AM
178 Posts
much better
thanks !
 
I did not know Evaluate was available in XPages...
 

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