Support

  • 1.  Displaying attachment file information in a velocity report

    Posted 07-23-2019 04:39
    Hello,
    I'm trying to include information about files attached to Jama items - the name, file name, description. I've seen another topic about this issue:
    https://community.jamasoftware.com/communities/community-home/digestviewer/viewthread?GroupId=25&MID=1694&CommunityKey=c9d20d4c-5bb6-4f19-92eb-e7cee0942d51&tab=digestviewer

    So i wrote a similar code myself:

    #set($docDao = $applicationContext.getBean("documentDao"))
    #set($docDao = $applicationContext.getBean("documentDao"))
    #set($documentTypeService = $applicationContext.getBean("documentTypeService"))
    #set($documentTypeFieldDao = $applicationContext.getBean("documentTypeFieldDao"))
    ###IMPORT DAO#
    #set($attachmentDao = $applicationContext.getBean("AttachmentDao"))

    ## getting a document list
    #foreach( $vDoc in $documentList )
      #set($doc = $vDoc.document) $vDoc.document.name<br>
      #set( $attachList = $docDao.getDocument_DocAttachments($mathTool.toInteger($doc.id)) )
      #foreach( $attachment in $attachList)
        $attachment $attachment.getAttachment()
        $attachmentDao.getAttachment( $mathTool.toInteger( $attachment.id))
      #end <br>
    #end

    However, this line does not work:
    #set($attachmentDao = $applicationContext.getBean("AttachmentDao"))
    Is there another name for attachment Dao? Maybe someone has another example of a code that exports information about attachments?

    thank you

    ------------------------------
    Roy Meirman,
    Zoll Medical Israel
    ------------------------------


  • 2.  RE: Displaying attachment file information in a velocity report

    Posted 07-29-2019 15:45
    Edited by roy meirman 07-29-2019 15:45
    ​I have changed the script a bit and now it works. it was "attachmentDao" without a capital A. this is an example of getting attachment information from an item called $vDoc which is a part of the $documentList in a context sensitive velocity report.


    #set($attachmentDao = $applicationContext.getBean("attachmentDao"))

         #set( $attachList = $docDao.getDocument_DocAttachments($mathTool.toInteger($vDoc.document.id)) )
         #if( $attachList.size() > 0)
         <table class=3DMsoNormalTable border=3D1 cellspacing=3D0 cellpadding=3D0 width=3D"100%"
          style=3D'width:100.0%;border-collapse:collapse;border:none;mso-border-alt:solid black .5pt;
          mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt;mso-border-insideh:
          .5pt solid black;mso-border-insidev:.5pt solid black'>
          <thead>
           <tr style=3D'mso-yfti-irow:0;mso-yfti-firstrow:yes;height:18.6pt'>
            <td width=3D"100%" style=3D'width:100.0%;background:#D9D9D9;mso-background-themecolor:
            background1;mso-background-themeshade:217;padding:0in 5.4pt 0in 5.4pt;
            height:18.6pt'>
            <p class=3DTableHeadingColumn>Attachment</p>
            </td>
           </tr>
          </thead>
          #foreach( $attachment in $attachList)
          <tr style=3D'mso-yfti-irow:1;mso-yfti-lastrow:yes'>
          <td width=3D"100%" style=3D'width:100.0%;background:white;padding:0in 5.4pt 0in 5.4pt'>
           #set($AttachmentItem = $attachment.getAttachment() )
           Attachment Name: $AttachmentItem.name<br>
           Description: $AttachmentItem.description<br>
           #set( $attachmentId = $AttachmentItem.getAttachment().getAttachment() )
           ## and only then we can use the int that we get for the $attachmentDao.getAttachment command.
           #set( $attachmentFile = $attachmentDao.getAttachment( $mathTool.toInteger( $attachmentId ) ) )
           File Name: $attachmentFile.getFileName()
          </td>
          </tr>
          
          </table>
          #end
         #end

    ------------------------------
    roy meirman
    zmi
    ------------------------------



  • 3.  RE: Displaying attachment file information in a velocity report

    Posted 07-30-2019 07:04
    Roy:

    A capital "A"? Amazing, thank you for sharing your solution here!

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------