One more way to automate business processes is to add Actions to a Document Solution. Actions automatically happen after you generate a new document.
If you use Google Docs or Google Sheets as the Document Template type then all Actions are available.
If you use DOCX or XLSX file types then you can create "Field Update", "Email Autosend", and "Email Preview" Actions.
To create a new Action follow the steps:
After you click New, the modal with the list of available Actions opens. You can choose only one Action and after that click Next to continue.
The Action updates the field on the related Object after you generate the document.
The following information is needed to set up the Action:
In the example from the screenshot above, after the Action is triggered, Stage Name on the selected Opportunity is changed to Proposal/Price Quote.
- If you would like to save the ID of the generated Google Doc or Sheet in your Salesforce field, please enter the following expression in the Value field: `{!Document_Request__c.External_File_Id__c}`. Using the same approach you can save any value from the Document Request record.
- Generated DOCX and XLSX files don't have such a field populated in Document Request, so instead you can save the ID of the generated file in the Salesforce field, using the following expression in the Value field: `{!Document_Request__c.File_Id__c}`.
If you are planning to have more than one Action on the Document Solution, you can execute them in a certain order by using the "Order Of Execution" field. Populate the corresponding field on each Action and they will be executed in the defined order. If you leave the field empty, the default value will be assigned to the corresponding Action.
You can notice that the "Mandatory Action" checkbox is marked by default. It means, that the result of the Action influences the next Actions in the queue. So if the Action fails, others get the "Cancelled" status. If the checkbox is unmarked, the failure of the Action doesn't affect the execution of the following Actions.
All the created Actions and their field values are exported and imported alongside the Document Solution.
If you want generated Google Docs to be deleted from Google Drive right after the generation process is over, you can use the "Delete Google File" Action.
Just select the corresponding Document Solution and click Save. Yes, as easy as that.
Order of Execution and Mandatory Action have the same functionality as was explained in the first Action.
This Action allows you to send the email with the generated document as an attachment.
Email Autosend Action has the following parameters to specify:
Order of Execution and Mandatory Action fields have the same functionality as was explained in the first Action.
To Email Address, Cc Email Address, and Bcc Email Address can accept multiple addresses or IDs separated with a semicolon (
;
).
If you would like to get recipients from the original record dynamically, you can use expressions in the following format{!Record.Field__c}
where "Field__c" is the name of the field where the recipient email or ID is stored. For example, the "To Email Address" field can holdoffice@mavenmule.com;{!Record.OwnerId};{!Record.Primary_Contact_Email__c}
.
For the Email Preview Action to work properly, make sure that the Activity component is open on the record where you generate the document.
With the Spring '23 Release, Salesforce introduced the Dynamic Activity Composer (DAC), which changed the way the Activity tab on Salesforce records behaves.
Currently, the Email Preview Action doesn't work with DAC. So you need to switch back to the Tabbed Activity View to have the Action available:
1. Click Edit Page in the "Setup" menu.
2. Select the "Activities" component.
3. In the "Properties" panel, check the "Use tabbed activity view" checkbox.
4. Save changes.
This Action is similar to the "Email Autosend" Action with the difference that you have the option to review an email before sending it to the customer.
After the document generation process is over, email fields are populated with the data you define while setting up the Action. The generated document is automatically attached to the email as well. Review the email or adjust it and then simply send it. The form for the "Email Preview" Action is identical to Email Autosend.
Order of Execution and Mandatory Action fields have the same functionality as was explained in the first Action.
The generated Google Docs or Google Sheets are saved in the same folder as the template Google Docs.
You might end up in a situation where your Google Drive folder is full of generated documents and you could find this a bit disorganized. This is where the "Move Google File" Action becomes useful. Using this Action you can move your newly created Google Docs or Google Sheets to the existing folder.
That is not all! The Action can also create subfolders to keep your Google Drive neat.
There are the following fields to be filled in while creating the Action:
Document Solution. Predefined with the name of the Document Solution you are working on.
This information is mandatory.
Root Folder Id. This is where you can copy/paste your Google Drive folder ID.
The folder ID can be found in the browser address bar, similar to the Google Docs ID described in previous chapters.
Generated Google Docs or Google Sheets are placed in this folder after it is created. This information is mandatory.
Create Subfolder. If you would like to organize your Google Drive, even more, Maven Documents can automatically create additional subfolders based on your Salesforce data. Check this checkbox if you would like to create subfolders.
Subfolder Path. Here is where you enter which subfolders you would like to create.
In our case, we have created two formula fields Month__c
and Year__c
that will contain the month and year in which the Opportunity is created. After our document is generated, Maven Documents automatically creates new folders in the root folder and it places the Google Docs into the created folder.
In the image below, Maven Documents automatically created two new folders: 2023
and 12
.
You don't need to worry about duplicate folders, Maven Documents makes sure it reuses already existing folders.
If you want to create multiple subfolders, split them with
/
.
For folder names, you can use either static text or you can use dynamic expressions like in our example.
Order of Execution and Mandatory Action fields have the same functionality as was explained in the first Action.
All the new Google Drive files that are generated with Maven Documents are initially owned by the Admin user who is connected to Google Drive. More information can be found in the Administration article.
If you use Google Docs or Google Sheets as the output format and would like to share the generated Google file with another person, let's say a customer, then use the Share Google File" Action.
Share Google File has the following parameters:
Document Solution. Predefined with the name of the Document Solution you are working on.
This information is mandatory.
Share Type. Defines the type of grantee that gets access to the Google Drive file.
This information is mandatory.
Share Role. Defines the role granted to the grantee.
This information is mandatory.
If you own the document, you can't share the ownership with another User. In that case, the Action Request ends up in an error.
Email Address. The email address of the grantee.
This field is populated only when the selected Type is User or Group.
Send Notification Email. If checked, after the document is generated and shared with the grantee, a notification email is sent to the grantee as if you are sharing your document manually.
This field is checked only when the selected Type is User or Group.
Domain URL. The domain to which this sharing refers.
This field is populated only when the selected Type is Domain.
The Email Address field supports dynamic expressions as displayed in the screenshot above.
If you share the file with multiple grantees, create multiple Actions on the same Document Solution.
Order of Execution and Mandatory Action fields have the same functionality as was explained in the first Action.
As you can say from its name, with the help of this Action you can copy the file that was generated and stored at OneDrive or Google Drive, and place it on the needed record on Salesforce. To accomplish that, you need the following data:
You can change the name of the file, define its format: either PDF or DOCX and how the file is saved on Salesforce: as a file or an attachment.
Currently, the "Copy Document to Salesforce" Action only supports Microsoft OneDrive DOCX files.
However, this action stands out from the ones we described above.
First of all, you won't find it in the list of available actions on a Document Solution. This Action is only available in a Flow.
Secondly, it is not a post-generation Action. That means, you can execute Copy Document to Salesforce regardless of whether the document was generated or this is not even in the picture. But of course, you can embed this Action in the document-generating Flow and use data from the Flow elements to create a process that suits your business logic most.
We wrote instructions to use the action both alone and as a part of the Flow. Follow the link to check it out.
This Action allows you to merge two or more separate PDF files into one:
All the PDF files that you want to merge should be preliminarily uploaded to Salesforce.
You won't find the Action in the list of available actions on a Document Solution. You can call it from the Flow or by inserting it with the code via the Developer Console.
We would say that using code is too technical, so you can check the article where we describe how to build the needed Flow and use the "Merge Files" Action there.