How to Merge Multiple Salesforce files into Single PDF using Salesforce Flows?

Nullam vel lectus vel velit pellentesque dignissim nec id magna. Cras molestie ornare quam at semper. Proin a ipsum ex. Curabitur eu venenatis

March 01, 2023
2429 Views
How to Merge Multiple Salesforce files into Single PDF using Salesforce Flows?
Requirement:

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:
  • Flow
  • Apex Classes (using synchronous or asynchronous methods like batch, future)
  • Lighting Component
  • Visualforce Pages / JavaScript
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:
https://www.filezipo.io/release-notes/


Screenshot 2023 02 09 at 00.46.49
User can click on the type of the org in which they need to process their files.

Step 2. Once installed, user will find two flows in their list of flows (displayed in the below table).


Screenshot 2023 02 09 at 01.09.08

  • 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.
Actions include:
  • 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:


Screenshot 2023 02 09 at 01.19.33
Step 4: Once the run button is clicked, it will display the below screen to the end user:


Screenshot 2023 02 09 at 01.21.49
The fields highlighted in above screenshot are defined as below:

  • 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.
Note:
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”


Screenshot 2023 02 09 at 02.13.22
On the next screen, it will display list of files for the user to select.


Screenshot 2023 02 09 at 02.14.41
Once the files are selected and next button is clicked, the sample flow will display the “Selected Files” in the next screen for confirmation. (User can skip this screen or change them accordingly)


Screenshot 2023 02 09 at 02.19.57 1
Step 6: Once the “Next” button is clicked, it will initiate the process of merging the files. The next screen will show the status bar for the number of items are processed and how many are remaining.


Screenshot 2023 02 09 at 02.27.16
Once the process is completed, its going to send an email to the user on the defined email address as shown in below image:


Screenshot 2023 02 09 at 02.39.37 1

Note:

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


Screenshot 2023 02 09 at 01.35.48

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Mohit Bansal

Salesforce Technical Architect | Lead | Salesforce Lightning & Integrations Expert | Pardot | 5X Salesforce Certified | App Publisher | Blogger

Leave a Reply

Your email address will not be published. Required fields are marked *

Contributor of the month
contributor
Mithun Naik

Software Engineer | Salesforce | 3X Certified Developer | Salesforce Blog Writer

Categories

Get the latest tips, news, updates, advice, inspiration, and more….

...
Boost Your Brand's Visibility

Want to promote your products/services in front of more customers?

...
0%
Think you know Salesforce?
Fill in the details to Get Started

What is true about dynamic dashboards?

A Salesforce Administrator has 7 million records that need to be loaded into Salesforce and wants to do it in one batch. How can the records be uploaded in one batch?

Which of the following statements are true about resetting passwords when users get locked out of a Salesforce org that does NOT have single sign-on enabled through an identity service other than Salesforce?

If a user is working in Salesforce when the login hours end, what will happen?

Which of the following can a Case Queue be used for?

Your score is

0%

This will close in 0 seconds