Easily set up and manage automation to merge documents when specific actions happen in Salesforce, like onboarding a new client, using Salesforce Flow —a go-to automated data collecting solution!
Setting up a successful Salesforce Flow is done in two parts:
- Create the document template
- Configure the Salesforce Flow
Important Note: The creation and maintenance of Flows are outside the scope of Formstack Support and any assistance provided will be limited.
Part 1: Create a document template and match it with Salesforce
Step 1: First, to successfully generate documents via a Salesforce Flow, create a document template with merge fields. This is a necessary prerequisite to mapping document fields to Salesforce fields.
Step 2: Set up mapping. After you have created your document template, navigate to the Formstack Mappings tab.
Here, select New Mapping and fill out the following fields:
- Mapping Name: Give your mapping a unique name
- Salesforce Object: Choose which object this document is being generated from such as a Salesforce Opportunity.
- Select a Formstack Resource: Keep this on “Document”
- Select a document: Locate the created document to populate the fields.
Then select Save and Next and follow the next set of prompts to select any optional settings.
Step 3: Match Formstack Fields to Salesforce Fields. The merge fields from the document will auto-populate; however, you will need to choose where to house these fields within Salesforce.
Select Save and Activate once mapped.
Step 4: Lastly, copy the Mapping ID from the top of the page. This will be used in your flow setup.
Part 2: Set up document generator using Salesforce Flow
Step 1: Navigate to Setup (gear icon). Then in Search, type “Process Automation” to locate and select Flows.
Step 2: Click New Flow and select “Record-Triggered Flow” from the available options.
Step 3: From the Configure Start pop-up, type in the Primary Object under Select Object and when to start the flow under Configure Trigger.
Make sure the primary object you select is the same as the primary object being used on the document you are creating the flow for.
Step 4: Set up any conditions (optional) and click Done to capture the configurations.
Note: While setting up conditional requirements is optional, it is helpful when a record is updated for an optimal experience in Salesforce Flows.
Step 5: Add an action. Select the Element (+ sign) and choose Action.
Search for “Document” or “Apex” to easily view and select the “Generate Document” option.
Step 6: Fill out the action.
From the New Action Screen, type in the Label to fit your naming convention and the API Name will auto-populate.
Then fill in input values.
- Salesforce Record ID: Type in “{!$Record.Id}”
- Webmerge Mapping ID: Paste in the Mapping ID from the Formstack Mappings tab shown in Part 1.
Once filled out, select Done to capture the actions.
Step 7: Save and activate the Salesforce flow.
Click Save.
Enter a Flow Label and select Save. Salesforce will automatically generate the API name.
Lastly, select Activate to turn on the Salesforce Flow.
(Optional) Generate documents for multiple records at once
Optionally, you can follow similar steps from above to generate documents for multiple records at once. This is similar to the previous method used for generating a document for a single record, but with the added benefit of handling multiple records simultaneously.
Note: It’s important to note that you can only choose one method for Generate Document action.
Here's a guide on how to use this feature effectively:
1. Getting Multiple Records in Flow
-
-With this feature, you can fetch multiple records at once. For instance, you can use a screen flow to get accounts matching a specific value.
-
- This can apply to any object, not just accounts—so you can fetch multiple records in bulk as needed.
2. Selecting and Processing Records in Bulk
-
- When you need to work with multiple records (for example, to generate documents for multiple accounts), you can retrieve all matching records in a single query.
-
- Instead of just retrieving a single account, you can get a collection of accounts that match your criteria.
- In the example below, we’re using the Get Accounts Label with our Get Records step in the flow. This step will be set up to select all the accounts matching a specific value. -
3. Generating Documents for Multiple Records
-
- After fetching the records, you can use the Generate Document action in Flow. This allows you to generate a document for each record in the collection.
-
- The key change here is that instead of processing a single record at a time, you can now pass the entire collection of records to the Generate Document action.
4. Using Variables and the Transform Feature
-
- A feature in Flow, called Transform, helps you efficiently convert collections from one type to another. In this case, you can transform a collection of records (e.g., accounts) into a collection of text (e.g., account IDs).
-
- With Transform, you can map the collection of records into a simpler collection that can be processed more easily, such as a list of text values (like account IDs).
Example:
-
- In the transform step, you select the field you want to work with (e.g., account ID) and convert the entire collection into a list of IDs.
-
- This step eliminates the need to loop through each record manually, making the process much more efficient.
5. Processing Documents for Each Record
-
Once you've transformed the data, you can pass the list of account IDs to the Generate Document action.
-
For every record in the collection, the system will generate a document based on the template, allowing you to generate multiple documents at once without complex looping or repetitive steps.
6. Benefits of this Method
-
This method of querying records in bulk and using transform improves both performance and efficiency. It helps you avoid the complexities of manually looping through records and ensures that you stay within governing limits while processing large amounts of data.
Manage existing Salesforce Flows
Manage your Salesforce Flows from Setup (gear icon) > Process Automation > Flows.
Here, all viewable flows are listed to select and take action on the ability to deactivate, save as a new flow to edit for additional Documents for Salesforce, edit an element, and debug.
Have any further questions? We’re here to help! Please reach out to support@formstack.com for additional assistance with your use case.
Are you looking for consultation or help building out your use case(s)? Team up with third party Certified Formstack experts to bring your custom projects to life.