How can you export an object’s attachments based on a user-defined date range of record created date?

The customer requirement involves a user being able to provide a date range to identify a set of custom object records. For all object records that fall within that date range (assuming the Created Date is used to filter), the system should then assemble all the records’ attachments and provide an output to download (zip or PDF).

Any thoughts?

Data export really won’t cut it here because the user needs to be able to specify a dynamic date range to filter records such as the records created in the last 7 days, last 30 days, etc.


RE: A Zip File Approach.

If a Zip file is OK and your happy to drive a solution via Visualforce page (client side processing). Then this Visualforce component library around the JSZip library will do what you want.

The demonstration on this blog shows unzipping and zipping (from attachments on a record) via an Office file (which is a zip file as it happens), using ZipFile custom object with attachments, however this the library itself is not bound to a specifc custom object, this is just an example one used in the blog.

NOTE: The resulting Zip file is sent back to VF page controller in the demo, however you could leave it on the client and use the JavaScript File IO libraries built into most browsers to save the file directly. Depending on the size of the resulting zip this will avoid any upload governors kicking in.

<c:zipfile name="someZipfile" state="{!ZipFile__c.Id}" 
   <apex:repeat value="{!paths}" var="path">
     <c:zipentry path="{!path}" base64="true"/>

 public static String getZipFileEntry(String path, String state)

enter image description here

Source : Link , Question Author : Steve Richardson , Answer Author : Andrew Fawcett

Leave a Comment