Now that you have created the Document Solution, used Query Builder to get Salesforce data, and created the Document Template for Sales Quote document, all that's left to do is to generate the document. There are many ways to do that, and we are going to show them to you in other sections. But now, you are going to do it in the easiest way possible – by simply clicking a button. To set that up, you need to add a Button Configuration, so let's do it.
Every Document Solution record can have multiple Button Configurations added to it. To add a Button Configuration:
Open Sales Quote Document Solution.
Type in the following field values:
Inside Sort Order field, input number 1. This marks how should Button Configuration be sorted out concerning each other.
Click Save.
And with that, the Button Configuration has been created.
If you would like to continue working with Google Docs instead of Salesforce Files or Attachments, use Google Drive as Save As option and Google Docs for the Document Format. To learn more about Save As Google Drive File option, go to Google Settings in Salesforce section.
Now, you need to create a Custom Action on 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 Object Manager tab, find Opportunity object and open it.
In Opportunity object setup page, open 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 New Action window, type in 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 a Page Layout.
To add Generate Quote Action to a Page Layout:
In Opportunity object setup page, open Page Layouts tab.
Open Opportunity Layout (or whatever layout you're using).
In Layout edit page, select Mobile & Lightning Actions tab.
Find Generate Quote Action and drag it to Salesforce Mobile and Lightning Experience Actions section.
After you've successfully added the action to the layout, click Save.
And 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.
You only need to create a Custom Action and add it to the layout the first time you're creating a Button Configuration for that object. After that, the existing component will just expand with more options 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. Here, you'll have to select a generic Salesforce Edge SLA Opportunity and add some Products to it to show you how it works.
When you've found the Opportunity that you want to generate a Quote for, click Generate Quote button (that's the Custom Action you created and added to the layout in the previous step).
Now, you can choose the format and whether you want to save it as a File or as an Attachment. If you are unsure about the differences between a File and an Attachment in Salesforce, this article might help. For the document, you'll select File and PDF format. When you've made your decision, click Generate Document.
After a few seconds, you'll get a success message if your document has been generated successfully.
If you get an error, it means something went wrong while trying to generate the document. We won't focus on that here, but you can get a detailed explanation about identifying and fixing some errors in FAQ section.
After generating a document successfully, you can find it in Notes & Attachments related list on our Opportunity record:
Once you press Generate Document, beside the new file or attachment, a new mmdoc__Document_Request__c record is also created. That record will always be created when Document generation has started with its creation, regardless if it is successful or not. More detailed information about Document Request you could find here.
And finally, here is how the document looks after generating:
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 your customer and close the deal.
Note: If you were using Google Docs or Google Sheets as an option for the Document Template, then the newly-generated document will also be added to your Google Drive, so you can access it from there as well. Unless you created the action which deletes the generated file from Google Drive.
Now you can see that the quote document turned out great, and we have the power of Maven Documents on full display here. From now on, you don't have to worry about anything else if you want to generate a quote for any other Opportunity record in the Salesforce org. All you have to do is open the record and generate the document from there.
And that's it, we have now shown you from start to finish how to generate your documents. If you want to continue learning about Maven Documents features, you can check Actions article to execute actions after your document is generated (e.g. send your Quote to the customer), Export/Import article to see how you can easily export and import your Document Solutions, or you can check Automate with Flow and Automate with Code articles to find out about generating documents from automated processes,
Some additional options are available on the Button Configuration. Let's check what can we do with these options.
By marking the checkbox you are disabling the preview of the document right 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 Notes and Attachments section.
With the help of this setting, you will be able to preview and edit the generating document Before Merge, After Merge, or Before and After Merge. It means that the document can be edited before or after the 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.
Here is how the process looks like if the Before Merge option is selected:
You select the Before Merge option in Document Preview multi-select picklist on Button Configuration
You generate the Document as you normally would
Because you selected the Before Merge option, Document Preview is now being shown. You can edit this Document 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 your original Document Template still stays the same - without the 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 After Merge option in Document Preview multi-select picklist on Button Configuration
You generate the Document as you normally would
Because you selected After Merge option, Document Preview is now being shown. You can edit this generated Document to your taste. Notice how the Document is already merged with all of the merged fields and mdoc elements.
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 edited before it is merged and before it is saved in Salesforce.
Here is how the process looks like if After Merge option is selected:
You select both Before Merge and After Merge options in the Document Preview multi-select picklist on Button Configuration
You generate the Document as you normally would
Because you selected Before Merge option, Document Preview is now being shown. You can edit this Document Template to your taste
Let's click Next here. (If you click Cancel - you will return to the previous step)
Because you also selected After Merge option, Document Preview is being shown again. You can edit this generated Document to your taste. Notice how the Document is already merged with all of the merged fields and mdoc elements.
As you can see, the Document is now saved in Salesforce with your custom changes applied.
This setting is only available for Google Docs and Google Sheets templates.
If you would like to make your Template available for users only if certain criteria are met (e.g. if Opportunity is closed, Order Template should be visible, otherwise it should be hidden), then this feature comes in handy. In the example, in the picture, it can be seen that this Button Configuration is Opportunity.IsClosed equals true. This field should contain SOQL condition syntax.
In the previous section, we showed how you can generate your documents the "usual way" - by opening mmdoc:GenerateDocument action. But you also have the option to create a shortcut in the form of the custom Quick Action.
That custom Quick Action will immediately run the document generation without any need for further user input. All you need to do is to create your Quick Action, add it to the layout as you would normally, and write its name inside Action Name field on the Button Configuration of your choosing.
Once that action is clicked, Maven Documents will immediately start to generate your document based on the Button Configuration record that contains your Action Name.
Your Action Name should not have any spaces, so make sure to input Action Name and not Action Label.
This field accepts any number, positive or negative. Once you select the Generate Document action, Maven Documents will then sort out the Templates based on those numbers.
If no number is added, sorting is done by using Template names.
If Reuse File checkbox is checked, the generated Document in the form of the Content Version will reuse the existing Content Document record, if such Content Document exists (if you have already generated documents before). Otherwise, a new Content Document (and Content Version) will be created each time you generate documents.
As it was mentioned earlier, there is an opportunity to save your document as a Google Drive file in Google Docs or Google Sheets formats. This option can be selected when you create or edit the Button Configuration. If you choose this option, the document is also created on Salesforce as the Google Doc link reference.
You can however only do this in the Classic version. So you should start by switching from Salesforce Lightning to Salesforce Classic. Click on your avatar in the top right corner of the page and, in the Options section, click on Switch to Salesforce Classic.
Then go to 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 Quick Find field and click on Google Apps Settings.
In Configure Google Apps Domains section fill out the form and click Save.
After that, in Activate Google Apps Services section, click Edit next to Add Google Docs to Salesforce.com field.
Check both checkboxes and click Save
And that is it! Now you will have the link to the generated Google Doc or Google Sheet in Notes and Attachments section on Salesforce. You can now switch back to Lightning Experience and check how it looks!
Go to the corresponding Object on Salesforce and run the generation process. Select Google Drive File in Save As field and Google Doc in Document Format field, and click Generate Document button.
After receiving the message that the Document is generated, go to Notes and Attachments section. There you will find the link that leads to the generated Google Doc on your Google Drive. The link looks like this:
Click on the link and you will see the hyperlinked message that you can't view the following item in the Lightning Experience, but you can open it in the 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 Google Doc.