Now that you have created Document Solution, used Query Builder to get Salesforce data, and created Document Template for the Sales Quote document, all that's left to do is to generate the document. There are many ways to do that: for example, you can build and run a Flow or use code solutions. But now, you are going to do it in the easiest way possible – just clicking a button. The frist step in that direction is addinng a Button Configuration, so let's do it.
Every Document Solution record can have multiple Button Configurations added to it. Here's how you can add a Button Configuration:
Open the Sales Quote Document Solution.
In the opened pop-up window, fill in fields with the following values:
Inside the Sort Order field, input 1. This value defines the position of the Button Configuration record in the corresponding list while setting up the generation process.
Click Save.
That is how you create the Button Configuration record.
If you would like to continue working with Google Docs instead of Salesforce Files or Attachments, use Google Drive as the Save As option and Google Docs for the Document Format field. If you want to learn more about the save as Google Drive File option, go to Google Settings in Salesforce section.
Now, you need to create a Custom Action on the Opportunity object to use it. Here is how to do that:
Open Setup by clicking the gear icon in the upper right corner and then selecting Setup.
In Setup, open the Object Manager tab, find the Opportunity object and open it.
In the Opportunity object setup page, open the Buttons, Links, and Actions tab and click New Action.
The action needs to show mmdoc:GenerateDocument Lightning Component and Maven Documents will take care of the rest. In the New Action window, use the following values:
Click Save.
The Custom Action has been created and is ready to use, but to use it you need to add it to the Page Layout.
That is how you can add the Generate Quote Action to the object's Page Layout:
In the Opportunity object setup page, open the Page Layouts tab.
Select Opportunity Layout (or whatever layout you're using).
In the Layout edit page, select the Mobile & Lightning Actions tab.
Find the Generate Quote Action and drag it to the Salesforce Mobile and Lightning Experience Actions section.
After you've successfully added the action to the layout, click Save.
With that, the Action is now added to the Opportunity Layout. You can now access it from every Opportunity record and create a Document Request for the quote.
Create a Custom Action and put it on the Layout when you use the related object in a Button Configuration for the first time. After that, the current component will automatically grow with additional choices when you add new Button Configurations.
After everything you've done so far, you can finally generate our quote document. All you need to do is open an Opportunity record and generate the quote from there. In this example, we will use the generic Salesforce Edge SLA Opportunity.
Ensure that the record you use for document generation contains all the necessary data you want to retrieve with the built query. For instance, make sure the record includes information about Products, Contacts or Amount.
Once the data is set, click the Generate Quote button (that runs the Custom Action you created and added to the layout in the previous step):
After a few seconds, you'll get a success message if the document has been generated successfully.
If you get an error, it means something went wrong in the generation process. We won't focus on that here, but you can get a detailed explanation about identifying and fixing some errors in the FAQ section.
After generating the document successfully, you can find it in the Notes & Attachments related list on the Opportunity record.
Once you press Generate Document, besides the new file or attachment, the new Document Request record is also created. That record will always be created when document generation starts, whether it is successful or not. More detailed information about Document Request you could find here.
And finally, here is how the document looks after generation.
As you can see, everything that we wanted to show is there: fields have been replaced with values, the table has been built with products added, and on the remaining pages, the link, the payment code, and other information have been successfully added to the quote document. You can now send it to a customer and close the deal.
Note: If you were using Google Docs or Google Sheets as an option for Document Template, then the newly-generated document will also be added to the Google Drive. Unless you use the Delete Google File Action which deletes the generated file from Google Drive.
That's it, we have now shown you from start to finish how to generate your documents. From now on, if you want to generate the quote for any other Opportunity record, all you have to do is open the record and click the Generate Quote button.
If you want continue learning about Maven Documents features, you can check the following pages:
There are also some additional options available in Button Configuration. Let's check what can we achieve with them.
With the help of this feature, you are able to preview and edit the generating document Before Merge, After Merge, or Before and After Merge. In other words, the document can be edited before or after the merge fields, added to the document with Template Builder, are replaced with the corresponding values from Salesforce.
By selecting these options, you are choosing when the document is previewed and optionally edited.
Document Template is previewed before it is merged and saved in Salesforce.
The Before Merge preview is only available for Google Docs and Google Sheets templates.
Here is how the process look like if the Before Merge option is selected:
You select the Before Merge option in the Document Preview multi-select picklist in Button Configuration.
You generate the document.
Since you've selected the Before Merge option, Document Preview is shown. You can edit the Template to your taste.
Let's click Next here. (If you click Cancel, you will return to the previous step)
As you can see, the document is now generated with your custom changes applied.
Note that the original Document Template stays the same, without changes you did in the Preview pane!
Document Template is previewed after it is merged, but before it is saved in Salesforce
Here is how the process looks like if the After Merge option is selected:
You select the After Merge option in the Document Preview multi-select picklist in Button Configuration.
You generate the document.
Since you've selected the After Merge option, Document Preview is shown. Notice that the document is already merged, with all of the merged fields and elements replaced by corresponding Salesforce values. However, you still can edit this generated document to your taste.
Let's click Next here. If you click Cancel,you will return to the previous step.
As you can see, the document is now saved in Salesforce with your custom changes applied.
Document Template is previewed before it is merged and before it is saved in Salesforce.
The Before Merge preview is only available for Google Docs and Google Sheets templates.
Here is how the process looks like if both Before and After Merge options are selected:
You select Before Merge and After Merge options in the Document Preview multi-select picklist on Button Configuration.
You generate the document.
Since you've selected the Before Merge option, Document Preview is shown. You can edit Document Template to your taste.
Let's click Next here. If you click Cancel - you will return to the previous step.
Because you've also selected the After Merge option, Document Preview is shown again. Notice that the document is already merged, with all of the merged fields and elements replaced by corresponding Salesforce values. But you still can edit this generated document.
Click Next one more time. As you can see, the document is now saved in Salesforce with all the changes you've made.
The feature comes in handy if you want the Template available for users only if certain criteria are met. For example, if the Opportunity record has status Closed, then Order Template should be visible, otherwise it should be hidden.
In the screenshot, you can see how to set that field in Button Configuration, following the example mentioned earlier.
This field should contain SOQL condition syntax.
We've already shown you how to generate the document by creating the custom Action. But you also have the option to create a shortcut in the form of the custom Quick Action. It will immediately run the document generation without any need for further user input.
Here is what you should do:
Once that Action is clicked, Maven Documents will immediately start to generate your document based on the Button Configuration record that contains that Action Name.
Action Name should not have any spaces, so make sure to input Action API Name and not Action Label.
Once you select the Generate Document action, Maven Documents will then sort the Templates based on those numbers. This field accepts any number, positive or negative.
If no number is added, sorting is done by using Template names.
If the Reuse File checkbox is checked, the generated document in the form of Content Version will reuse the existing Content Document record, if such Content Document exists. Otherwise, new Content Document and Content Version will be created each time you generate documents.
By marking the checkbox you are disabling the preview of the document after the generation process is ended. You'll still see a green toasted message on successful generation but the preview of the document won't be shown. You will find the generated document in the Notes and Attachments related list on the corresponding record.
As it was mentioned earlier, there is an opportunity to save your document as a Google Drive file in the Google Docs or Google Sheets format. This option can be selected when you create or edit Button Configuration. If you choose this option, the document is also created on Salesforce as the Google Docs link reference.
However, you can only do this in the Classic version of Salesforce. So you should start by switching from Salesforce Lightning to Salesforce Classic:
Click on your avatar in the top right corner of the page.
In the Options section, click on Switch to Salesforce Classic.
Then go to the Setup settings by clicking on your username in the top right corner of the page and selecting the Setup option in the dropdown menu.
On the Setup settings page, write down "Google" in the Quick Find box and click on Google Apps Settings.
In the Configure Google Apps Domains section, fill in the form and click Save.
After that, in the Activate Google Apps Services section, click Edit next to the Add Google Docs to Salesforce.com field.
Check both checkboxes and click Save.
That is it! Now you will have the link to the generated Google Docs or Google Sheets file in the Notes and Attachments related list on the corresponding record in Salesforce.
You can now switch back to Lightning Experience and check how it looks:
Go to the corresponding record in Salesforce and run the generation process.
Select Google Drive File in the Save As field and Google Doc in the Document Format field.
Click the Generate Document button.
After receiving the message that the document is generated, go to the Notes and Attachments related list. There you will find the link to the generated Google Docs file on your Google Drive. The link looks like this:
Click on the link and you will receive the hyperlinked message that you can't view the following item in the Lightning Experience, but you can open it in Salesforce Classic.
Once you click on the message, you'll be redirected to the following page:
There you will find the corresponding URL and some other pieces of information regarding the generated Google Docs file.