How to Merge 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
  • Follow us
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/


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).


  • 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:


Step 4: Once the run button is clicked, it will display the below screen to the end user:


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”


On the next screen, it will display list of files for the user to select.


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)


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.


Once the process is completed, its going to send an email to the user on the defined email address as shown in below image:


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


Looking for more exciting content like this?

Ayan Softwares provides quality Salesforce content written by Top Salesforce MVP’s and Admins

Explore All Blogs
written By

Mohit Bansal

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

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

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?

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

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

What is true about dynamic dashboards?

Your score is

0%

This will close in 0 seconds