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 a couple of 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 first step in that direction is adding 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.
At this point we will describe parameters that are the most important for both Google and Azure templates.
In the opened pop-up window, fill in fields with the following values:
Keep in mind, that the Object Name field should contain the API name of the object.
- Select the OneDrive option, if you would like to save the generated file on OneDrive. It allows you to further collaborate with other users on the generated document by editing or sharing it.
- Select the Google Drive option, if you would like to continue working with Google Docs instead of Salesforce Files or Attachments. For this option to work correctly, you should also select Google Docs for the Document Format field. If you want to learn more about the save as Google Drive File option, go to the Google Settings in Salesforce section.
- Select the XLSX or CSV option, if you would like to work with the generated document in Microsoft Excel. These formats are only available for Google Sheets and XLSX Document Templates.
- Select the Google Doc or Google Sheet option, if you would like to save the generated file only on Google Drive. In that case, you will have a link to the generated file in the Notes & Attachments section on Salesforce.
That is how you create the Button Configuration record.
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 Amounts.
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. You can find more detailed information about Document Request 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 to 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 can 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.
The template document 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 looks 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 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 generated with your custom changes applied.
Note that the original Document Template 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
For DOCX and XLSX templates, the After Merge Preview only works if the Save As OneDrive option is selected.
Here is how the process for Google templates 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.
The same functionality works a little bit differently for Azure templates:
Having value in one of the Share User Edit List or Share User View List fields or having the Create Shareable Edit Link or Create Shareable View Link checkbox marked is the prerequisite for the After Merge Preview option of the OneDrive file. If you don't have any of them populated, the generation process will not even start: the validation error is thrown.
Select only the OneDrive option in the Save As field and the After Merge option in the Document Preview multi-select picklist in Button Configuration.
Fill the Share User Edit List or Share User View List field in with the email address of a user, or mark the Create Shareable Edit Link or Create Shareable View Link checkbox.
Generate the document with the corresponding options.
There are two ways how Preview works, depending on which type of fields you used: Share User List or Create Shareable Link.
To edit this document to your taste in the Preview frame on Salesforce, click on the Full-Screen button in the bottom right corner of the Preview Frame. The merged file created on OneDrive opens in a new tab in the View mode.
If you have a preview on OneDrive, click the link that you have on your screen.
So let's click Next here. If you click Cancel, you will return to the previous step.
As you can see in the final Preview, the document is now saved with your custom changes applied. You can go to OneDrive and double-check it.
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 the template document 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 the status Closed, then the 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 a 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.
Using this field makes sense when you are generating the Document as a OneDrive file.
In this field, you can place the email addresses of users who will have Edit access to the generated file on OneDrive. For others, the file will be in the Read Only mode. The link to the file can be found in the corresponding Document Request record. On OneDrive, you can see how it looks in the Manage Access setting of the file.
Using this field makes sense when you are generating the Document as a OneDrive file.
In this field, you can place the email addresses of users who will have View access to the generated file on OneDrive. The link to the file can be found in the corresponding Document Request record. On OneDrive, you can see how it looks in the Manage Access setting of the file.
Using this field makes sense when you are generating the Document as a OneDrive file.
By marking this checkbox, you are making the generated file on OneDrive available for editing to anyone who has the link to it. The link can be found in the corresponding Document Request record. On OneDrive, you can see how it looks in the Manage Access setting of the file.
Using this field makes sense when you are generating the Document as a OneDrive file.
By marking this checkbox, you are making the generated file on OneDrive available for viewing to anyone who has the link to it. The link can be found in the corresponding Document Request record. On OneDrive, you can see how it looks in the Manage Access setting of the file.
There are two things to keep in mind regarding shareable lists and links:
- If Share User Edit List and Share User View List fields are left empty, and Create Shareable Edit Link and Create Shareable View Link checkboxes are left unmarked, the generated file appears on OneDrive in the Private mode, and no link is shown in the corresponding Document Request record.
- Having value in one of the Share User Edit List or Share User View List fields or having the Create Shareable Edit Link or Create Shareable View Link checkbox marked is the prerequisite for the After Merge Preview option of the OneDrive file. If you don't have any of them populated, the generation process will not even start: the validation error is thrown.
We summarised the information on sharing access in the table below.
Field | Shared with | Preview |
---|---|---|
Share User Edit List | Only specified users can edit, other users don't have document access | On OneDrive |
Share User View List | Only specified users can view, other users don't have document access | On OneDrive |
Create Shareable Edit Link | Anyone with the link can edit | In the Salesforce pop-up window |
Create Shareable View Link | Anyone with the link can view | In the Salesforce pop-up window |
Using these 4 options, you can tailor access to the generated file according to your preferences and security policies.
As 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.
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.