Create Zip Files Comprising Many Attachments


The qbo.Attachment.Xceed IGenerator plugin has the ability to create zip files from other Attachments. This is useful for delivering a bunch of data to a client's FTP site, passing to an imaging system for processing, or other such use cases.


The simplest way to configure a recurring job is to:
  • Create an Attachment Template named 'All files for an Organization in one Zip file' (you are welcome to choose another name)
  • In the template's Applies to, enter 'Organization'
  • In the template's Method, enter Attachment/ListWhere?Object={Object}&ObjectID={ObjectID}
    • Note that the ZipGenerator plugin requires an AttachmentID, PathURL, and FileObjectAssembly columns to work
  • Choose Options > Generate, and generate it for your favorite OrganizationID
    • this just calls Attachment/Generate?Template=All files for an Organization in one Zip file&Object=Organization&ObjectID=1
This will create an Attachment containing all the Attachments bound to the Organization you chose.

The problem is, if you want to do this on a recurring basis, you should keep track of which attachments have already been zipped up, and just include those attachments that have not yet been zipped.

This can be handled using the Zip Generator's 'Link' ability.

Linking Objects

The QBO ObjectLink table is used to track relationships between objects.  In this example, when we zip up a bunch of Attachments, it'd be nice to know which zip file the attachment was linked to.  The Zip Generator will pay attention to a Link parameter.  If present, an ObjectLink will be created between the Attachment being zipped and the Zip file attachment.  For example, assume the following attachments exist:
  • Photo1.jpeg (ID=27)
  • Photo2.gif (ID=28)
  • MyAppraisal.pdf (ID=12)
  • TaxRecords.tif (ID=72)
When generating the Zip file:

Attachment/Generate?Template=All files for an Organization in one Zip file&Object=Organization&ObjectID=1&Link=Organization Zipped

a new Attachment named 'All files for an Organization in one Zip file' will be created with, oh, say AttachmentID 121.  In addition, 4 ObjectLink records will be created, one for each of the 4 attachments above, with:
  • PrimaryObject = 'Attachment'
  • PrimaryObject = 121
  • LinkedObject = 'Attachment'
  • LinkedObjectID = 27 | 28 | 12 | 72
Great; now our DBA can tell us which Attachments have been zipped!

Ignoring Already-Linked Attachments

Reverting back to our Attachment Template's Method, it was:


We can restrict the attachments returned with a simple parameter:

Attachment/ListWhere?Object={Object}&ObjectID={ObjectID}&NotLinkedFrom=Organization Zipped

The ListWhere query will leverage the NotLinkedFrom filter to ensure that only rows without an ObjectLink record called 'Organization Zipped' will be returned.