I was recently tasked with the challenge of creating ZIP files in Salesforce and saving them as attachments on records. In case you didn’t know, Salesforce doesn’t natively support doing this seemingly simple task within Apex. That means I was left to come up with a more clever solution…
The goal of this particular project was to create a number of XML files, then zip them up and attach the ZIP file to a record. The ZIP file would then be sent to a third-party service for processing. While this is a somewhat specific use case, there are a lot of other use cases where it might be necessary to create ZIP files in Salesforce.
The final step is the easiest–simply create a custom button and add the button to the Account page layout. The button will load the new Visualforce Page and initiate the ZIP file creation. Below is a screenshot of the button configuration. Try it out for yourself, and let me know what you think of my solution for creating ZIP files in Salesforce in the comments below!