Alex need to print 1000 pdf files stored in salesforce across multiple objects or records. As per salesforce standard, there is no out-of-box functionality to merge without downloading the files. User needs to download the files and use any external tool to merge them or print them one by one manually.
These type of work requests would take much more effort and time for an end user. In order to overcome this situation, here we are introducing the “AYAN PDF” – an api kit for all your needs.
Using AYAN PDF merge apis, user can easily merge any number of files in salesforce using multiple ways.
User can merge Files using AYAN PDF Apis in multiple ways:
- Apex Classes (using synchronous or asynchronous methods like batch, future)
- Lighting Component
Benefits of using AYAN PDF Apis to merge files:
- User can merge any number of files in single click
- User can merge any type of files (like Salesforce Files, Attachment, Documents)
- User can call these apis in multiple ways as highlighted in above table
- Simple and easy to integrate
How can we merge files using AYAN PDF Apis?
User can merge multiple files into single pdf in two ways:
- Calling AYAN PDF Apis in Apex/Aura – Being a Salesforce Developer, user can use the below two apis to merge files in few clicks.
- Calling Predefined Flow – Our Appexchange solution “File ZIPO”, uses the AYAN PDF Apis to merge multiple files into Single File. Once installed, user can call a predefined “Merge Flow” which is a part of this managed package, in which user needs to pass few parameters and files will be merged and sent to the email address defined by the user.
Let’s learn how to do it step by step:
Few Simple Steps to Merge Salesforce Files using pre-defined FLOW in File ZIPO:
Step 1. Install the latest version of Salesforce Appexchange application called “File ZIPO” using below link:
Step 2. Once installed, user will find two flows in their list of flows (displayed in the below table).
- Merge Files Using AYANPDF API – this is the main flow which needs to be called to initiate the process for merging the files. The sample flow also calls this main flow.
- Merge Files Reference Flow using APIs – this is the reference / testing flow which guides user with the ways to merge files in multiple ways. In this sample flow, user can call the below actions and try to merge files using apis.
- Allow user to find & select attachments and send for merge
- Allow user to find & select files and send for merge
- Allow user to find & select documents and send for merge
- Allow user to find attachments and send for merge (without selection)
- Allow user to find files and send for merge (without selection)
- Allow user to find documents and send for merge (without selection)
- Allow user to merge AWS S3 public files into single pdf file
Step 3. User can create its own flow here or can refer next few steps in which we will use the “sample flow” to explain how user can call the “main flow” and pass its parameters.
Just click on sample flow name and click this “run” button:
- Receipient Name – defines the name of the person who has submitted the request
- Merged File Name – defines the name of the merged file name which should be sent to the user
- Receipient Email – defines the email of the recipient user
- Receipient cc address – this is optional field
- Choose Action type – defines the type of action with which user needs to test the apis.
This is reference or sample flow only. User can clone or edit this flow and can make the changes to it to test different scenarios.
Step 5: Once the “Next” button is clicked, depending upon the action selected, it will display the next screen. Let’s take an example that user has selected the action as “Allow user to select files and merge”
The Steps 4, 5, 6 has gathered the different type of information as highlighted in below table from the UI Screens. These parameters needs to be passed to main flow “MergeFiles Using AYANPDF API” to initiate the merge process.
- Recipient Name – Defines the name of the person who has submitted the request
- Merged File Name – Defines the name of the merged file name which should be sent to the user
- Recipient Email – Defines the email of the recipient user
- Receipient cc address – Defines if need to add anyone in CC (this is optional field)
- selectedRecordType – Defines the type of record we are trying to merge. It can contains either one of these three values: Attachment, File or Document
- selectedRecordIds – Defines the list of record Ids of any of three objects (Attachment, Content Version, Document). Please don’t combine the Ids of multiple entity in single list.
- selectedAttachment_List – Defines the list of Attachments records which needs to be merged
- selectedDocument_List – Defines the list of Document records which needs to be merged
- selectedFile_ContentVersion_List – Defines the list of Content Version records which needs to be merged
Looking for more exciting content like this?
Ayan Softwares provides quality Salesforce content written by Top Salesforce MVP’s and AdminsExplore All Blogs