Support

 View Only
  • 1.  Include attachments in Velocity Reports (HTML/Word)

    Posted 10-09-2022 07:10
      |   view attached
    I am not able to return the document attachment list in my velocity reports.  I have attached a sample vm file (context sensitive) and included the contents below. This file was derived from an existing discussion (Displaying attachment file information in a velocity report)

    <html>
    #set( $attachmentDao = $documentSource )
    <head>
    <body>
    <br>Size: $documentList.size()</br>
    #foreach($vDoc in $documentList)
    <br>document: $vDoc.document.name</br>
    #set( $attachList = $docDao.getDocument_DocAttachments($mathTool.toInteger($vDoc.document.id)) )
    #if( $attachList.size() > 0)
    #foreach( $attachment in $attachList)
    #set($AttachmentItem = $attachment.getAttachment() )
    Attachment Name: $AttachmentItem.name<br>
    Description: $AttachmentItem.description<br>
    #set( $attachmentId = $AttachmentItem.getAttachment().getAttachment() )
    #set( $attachmentFile = $attachmentDao.getAttachment( $mathTool.toInteger( $attachmentId ) ) )
    <br>File Name: $attachmentFile.getFileName()</br>
    #end
    #end
    #end
    </body>
    </html>

    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------

    Attachment(s)



  • 2.  RE: Include attachments in Velocity Reports (HTML/Word)
    Best Answer

    Posted 10-12-2022 01:36
    Hi Jeff!

    This is the code I am using (Jama 8.74):

    ## retrieve attachment(s) info​
    #set($attachments=$documentSource.getDocument_DocAttachments​($doc.getId()))
    #foreach($attachment in $attachments)
    #set($attachmentInfo={
    "attachmentId" : $attachment.getAttachment().getAttachment(),
    "fileName" : $documentSource.getAttachment($attachment.getAttachment().getAttachment()).getFileName(),
    "name": $attachment.getAttachment().getName(),
    "description" : $attachment.getAttachment().getDescription()})
    #set($foo=$attachmentInfos.add($attachmentInfo))
    #end

    ## display in a table row (attachment name and URL pointing to the attachment)
    #foreach($attachmentInfo in $attachmentInfos)
    <tr>
    <td>$attachmentInfo.name</td>
    <td><a href=${baseUrl}/attachment/${attachmentInfo.attachmentId}/v/${attachmentInfo.fileName}>
    $attachmentInfo.fileName</a></td>
    </tr>
    #end

    Hope it helps. 

    Kind regards,

    ------------------------------
    Peter Lampacher
    MED-EL
    Innsbruck
    ------------------------------



  • 3.  RE: Include attachments in Velocity Reports (HTML/Word)

    Posted 10-12-2022 07:21

    Thanks Peter!
    This works well.



    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------