Clarity

  • 1.  Read Attachment on Object (Files Stored in DB)

    Posted Jan 31, 2018 11:16 AM

    I'd would like to read a file stored in an attachment field on a custom object (or any object) into a process and then xog that data in to the system. We are storing files in the DB, not the app file store.  

     

    I've done plenty of processes reading a file from a directory on the app server, shared drive, etc. But I don't know how to find the file name/path etc for a file saved in the DB. 

     

    Thanks.  



  • 2.  Re: Read Attachment on Object (Files Stored in DB)
    Best Answer

    Posted Feb 01, 2018 02:05 AM

    Hi derrickat ,

     

    I will suggest you to use Gel and XOG read of that object by passing a temporary document location as shown below:

    <NikuDataBus>
    <Header action="read" externalSource="NIKU" objectType="customObjectInstance"
             version="${ClarityVersion}">

       <args name="documentLocation" value="${xogDocumentDir}"/>
      </Header>
      <CustomObjectInstanceQuery>
         <Filter criteria="EQUALS" name="objectCode">z_fin_file_load</Filter>
         <Filter criteria="EQUALS" name="instanceCode">${FinLoadDtlRow.code}</Filter>
      </CustomObjectInstanceQuery>
    </NikuDataBus>

     

    By this you can xog out file to a teamporary location, however xog file and folder will be in raw form and you need to use sql to get folder 1 & 2 along with file name.

     

    select
         tpm.name
         ,tpm.code
         ,tpm.id
         ,tpm.z_aib_act_file
         ,cast(flv.id as char) file_version_id
         ,substring(cast(flv.id as char),2,3) path_one
         ,'00'+substring(cast(flv.id as char),1,1) path_two
         ,fl.name file_name
         ,fl.mime_type
         
    from
         odf_ca_z_fin_file_load tpm
    left outer join CLB_DMS_FILES FL on FL.PARENT_FOLDER_ID = tpm.z_aib_act_file
    left outer join CLB_DMS_VERSIONS FLV on FLV.FILE_ID = FL.ID

    where
         tpm.id = ${gel_objectInstanceId}

     

    So file can be access by location as below:

    ${xogDocumentDir}/Files/${path1}/${path2}/${thisDocumentId}

    Once you are able to  access this file then you can rename and use that as you want.

     

    Regards,

    Prashank Singh



  • 3.  Re: Read Attachment on Object (Files Stored in DB)

    Posted Feb 02, 2018 05:05 PM

    That worked perfectly. 

     

    Thanks, Prashank!