Now that you have created the Document Solution, used the Query Builder to get Salesforce data, and created the Document Template for the "Sales Quote" document, all that's left to do is to generate the document.
There are several 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 to add a Button Configuration, so let's do that.
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 describe parameters that are most important for both Azure and Google templates.
In the opened window, fill in the fields with the following values:
Keep in mind, that the "Object Name" field should contain the "API" name of the object.
Document Solution. The field is prepopulated with the name of the "Sales Quote" Solution.
If you are creating the Button Configuration from the "Document Template" record, then the list of available Document Solutions is provided in this field.
Document Template. The list of available Document Templates is shown in this field.
Choose "Sales Quote Template" as the Document Template.
If you are creating the Button Configuration from a Document Template record, the field is prepopulated automatically.
- 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" in 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 "XLSX" and "Google Sheets" Document Templates.
- Select the "Google Doc" or "Google Sheet" option, if you would like to save the generated file on Google Drive only. In that case, you get the link to the generated file in the "Notes & Attachments" related list on Salesforce.
- You can also select the "PDF" format for "XLSX" and "Google Sheets" Document Templates. In that case, the template Book is converted to a PDF file after generation.
That is how you create the "Button Configuration" record.
The next step is to create a custom Action on the "Opportunity" Object. This Action generates the template document using values from the Button Configuration.
Open Setup by clicking the "gear" icon in the upper right corner and selecting Setup.
In Setup, open the "Object Manager" tab, navigate to "Opportunity" Object and open it.
In the "Opportunity" Object setup page, open the "Buttons, Links, and Actions" tab and click New Action.
In the "New Action" window, set up the following values:
Click Save.
The custom Action has been created and is ready. To use it, you need to add it to the Object's 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 "Edit Layout" 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 "Generate Quote" 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 the 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 the 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, ensure the record includes information about products, contacts, or amounts.
Once the data is set, click the "Generate Quote" button. The button triggers the Action you created and added to the layout in the previous step:
If you are unsure about the difference between the File and Attachment on Salesforce, this article might help.
After a few seconds, you receive a "Success" message if the document was successfully generated.
If you get an error, it means something went wrong in the generation process. Check the 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 created. The record is created after generation, regardless of whether it is successful or not. You can find more detailed information about the Document Request here.
And finally, here is how the document looks after generation.
As you can see, everything we intended to demonstrate is present: the fields have been replaced with values, the table has been created with the products added, and on the remaining pages, the link, payment code, and other information have been successfully included in the quote document. You can now send it to a customer and close the deal.
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 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 the Button Configuration. Let's check what we can 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 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 on Salesforce.
The "Before Merge" preview is only available for Google Docs and Google Sheets templates.
Select the "Before Merge" option in the "Document Preview" multi-select picklist in the Button Configuration.
Generate the document.
Since you've selected the "Before Merge" option, the Document Preview is shown. You can edit the document to your taste.
Let's click "Next" here. (If you click "Cancel" you return to the previous step)
As you can see, the document is now generated with your custom changes applied.
The original Document Template stays the same, without the changes you did in the "Preview" pane!
The Document Template is previewed after it is merged, but before it is saved on Salesforce.
Select the "After Merge" option in the "Document Preview" multi-select picklist in the Button Configuration.
Generate the document.
Since you've selected the "After Merge" option, the Document Preview is shown. The document is already merged, with all the merged fields and elements replaced by corresponding Salesforce values. However, you can still edit this generated document to your taste.
Click "Next" here. If you click "Cancel" you return to the previous step.
As you can see, the document is now saved on 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. If you don't have any of them populated, the generation process doesn't start: the validation error is thrown.
Fill the "Share User Edit List" or "Share User View List" field 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.
The Preview works in two ways, 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.
After you click "Edit Document" and select the "Edit" option, you will be free to make changes to the merged file.
Once you are done, close the tab.
You are returned to the "Preview" frame on Salesforce.
To see the changes in preview, click the "Refresh" button.
If you have a preview on OneDrive, click the link you have on the screen.
Click "Next" here. If you click "Cancel" you 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.
The 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 looks if both "Before" and "After Merge" options are selected:
Select "Before Merge" and "After Merge" options in the "Document Preview" multi-select picklist in the Button Configuration.
Generate the document.
Since you've selected the "Before Merge" option, the Document Preview is shown. You can edit the template document to your taste.
Click "Next" here. If you click "Cancel" you return to the previous step.
Because you've also selected the "After Merge" option, the Document Preview is shown again. Note that the document has already been merged, with all fields and elements replaced by their corresponding Salesforce values. But you can still edit this generated document.
Click "Next" one more time. As you can see, the document is now saved on 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 "Closed" status then the "Order" Template should be visible. Otherwise, it should be hidden.
In the screenshot, you can see how to set that field in the 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 a custom "Quick Action". It will automatically run the document generation without requiring any further user input.
Here is what you should do:
Once that Action is clicked Maven Documents immediately starts generating your document based on the "Button Configuration" record that contains that Action Name.
The Action Name should not have any spaces, so ensure to input the Action API Name and not the Action Label.
Once you select the "Generate Document" Action, Maven Documents sorts Document Templates based on the Sort Order numbers. This field accepts integers.
If no number is provided, sorting is based on the Document Template names.
If the "Reuse File" checkbox is selected, the generated document (as a Content Version) reuses an existing Content Document record, if one exists. Otherwise, a new Content Document and Content Version are created each time you generate a document.
By marking the checkbox you are disabling the preview of the document after the generation process is ended. You’ll still see a green toast message upon successful generation, but the document preview will not be displayed. 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 the "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.
- Emails in the lists are separated by a comma.
- If sharing fails for any of the listed email addresses, those emails are displayed in the "Failed_Document_User_Edit_URL__c" or "Failed_Document_User_View_URL__c" field on the respective Document Request.
Using this field makes sense when you are generating the document as a OneDrive file.
By selecting this checkbox, you make the generated file on OneDrive editable by anyone with the link. 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 summarized 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, you have the option to save your document as a Google Drive file in either Google Docs or Google Sheets format. This option can be selected when you create or edit Button Configuration. If you choose this option, Salesforce will also generate a hyperlink.
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’s it! You will now find the link to the generated Google Docs or Google Sheets file in the "Notes and Attachments" related list on the corresponding Salesforce record.
You can now switch back to Lightning Experience and check how it looks:
Go to the corresponding record on 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 find the link to the generated Google Docs file on your Google Drive. The link looks like this:
Clicking the link will display a message informing you that the item cannot be viewed in Lightning Experience, but it can be opened in Salesforce Classic.
Once you click on the message, you'll be redirected to the following page:
There, you will find the corresponding URL along with additional information about the generated Google Docs file.