Include attachments in Velocity Reports (HTML/Word)
Jeff Abbott
Member, Data Exchange Posts: 31
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
------------------------------
<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
------------------------------
0
Comments
-
Peter Lampacher Member, Jama Connect Interchange™ (JCI), Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 14Hi 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
------------------------------
-------------------------------------------
Original Message:
Sent: 10-09-2022 07:09
From: Jeff Abbott
Subject: Include attachments in Velocity Reports (HTML/Word)
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
------------------------------
0 -
Thanks Peter!
------------------------------
This works well.
Jeff Abbott
Leidos
Orlando FL
------------------------------
-------------------------------------------
Original Message:
Sent: 10-12-2022 01:36
From: Peter Lampacher
Subject: Include attachments in Velocity Reports (HTML/Word)
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
------------------------------
Original Message:
Sent: 10-09-2022 07:09
From: Jeff Abbott
Subject: Include attachments in Velocity Reports (HTML/Word)
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
------------------------------
0