When you click Generate Document, you anticipate a new file in Salesforce with data from your template. Besides the file, a new record named mmdoc__Document_Request__c is also made. This record is crucial for document creation and is the main part of the entire application. It's always created when document generation begins, whether successful or not.
Document Requests are invoked by inserting them into the database, with the only exception being Batch Processing Type, which needs to be run separately to start generation.
We can check the status of document generation by checking the Status__c
field on requests:
New
. The processing has not yet started.Processing
. The request is currently generating.Completed
. The document has been generated and is available in whatever format and location you specify.Error
. Document Generation ended up in an error. The error message will be available in the Error_Message__c
field, providing more information on what went wrong.Cancelled
. The processing was cancelled.The newly created Document Request can only have the New status.
Just like every object in the Salesforce system, there are different ways of inserting them. The main is through Flows and Apex Code. Buttons can also be generated for record pages tied with Document Query. These buttons can be placed on a single record's layout, and allow for record-specific document generation.
Here are the fields that the Document Request record contains, so you have a better idea of what it represents in the app:
Field API Name | Values / Type | Description |
---|---|---|
Name |
Auto Number |
Name of the record, automatically assigned by the app. |
OwnerId |
Lookup(User,Group) |
Lookup to the owner of the record. |
Record_Id__c |
Text |
ID of the record that document generation started from. |
Status__c |
New , Processing , Completed , Error , Cancelled |
Current status of the record. |
Document |
Lookup |
Lookup to the Document Template record that this Document Request is using. |
Document |
Lookup |
Lookup to the Document Solution record that this Document Request is using. |
Document |
Text |
The title of the generated document. |
Document |
PDF , DOCX , Google Doc , Google Sheet , XSLX , CSV |
What (file) format should be the result of the document generation action. |
Save |
Salesforce File , Salesforce Attachment , Google Drive File , OneDrive |
How should the generated document be saved. |
Processing |
Queue , Batch , Synchronously |
How the record is processed. |
Error |
Long Text Area |
Descriptive text containing an error message if such an error occurred. |
Reuse_File |
Checkbox |
If checked, the Content Version will be linked to the existing Content Document (if it exists). Otherwise, a new Content Document will be created. |
Network |
Text |
Salesforce Community/Network ID that will be applied to the Salesforce File. |
Share_ |
Long Text Area |
Comma-separated values of users' emails, that will have the "Edit" permissions to the generated document. |
Create_ |
Checkbox |
If checked, the OneDrive link with "Edit" permissions will be created. |
Share_ |
Long Text Area |
Comma-separated values of users' emails, that will have the "View" permissions to the generated document. |
Create_ |
Checkbox |
If checked, the OneDrive link with "View" permissions will be created. |
PDF_Conformance_Level__c |
PdfA1a , PdfA1b , PdfA2a , PdfA2b , PdfA2u , PdfA3a , PdfA3b , PdfA3u |
Levels of conformance for PDF documents. |
PDF_Version__c |
PDF_1_0 , PDF_1_1 , PDF_1_2 , PDF_1_3 , PDF_1_4 , PDF_1_5 , PDF_1_6 , PDF_1_7 , PDF_1_8 , PDF_2_0 |
The version of the PDF specification to which the PDF document conforms. |
Embedded_Data__c |
Long Text Area |
JSON that should be embedded in the document. |
Language__c |
Text |
Defines the language of the Template Label. |
Locale__c |
Text Area |
Defines the locale, in which data is shown in the generated document. |
Folder_Path__c |
Long Text Area |
Defines the destinationpoint of the generated document on Drive. |
External |
Text |
The ID of the generated document in the external system (e.g. Google Drive). |
External |
Text |
Name of the generated document in the external system (e.g. Google Drive). |
File |
Text |
Salesforce File or Attachment ID. |
External_ |
Long Text Area |
The URL of the generated document in the external system (e.g. Google Drive). |
External_ |
Long Text Area |
The URL of the generated document with the "Edit" access on OneDrive. |
External_ |
Long Text Area |
The URL of the generated document with the "Edit" access to the defined users on OneDrive. |
External_ |
Long Text Area |
The URL of the generated document with the "View" access on OneDrive. |
External_ |
Long Text Area |
The URL of the generated document with the "View" access to the defined users on OneDrive. |
Page_Count_Generate__c |
Number |
Stores the number of pages in the Generate Document operation. |
Page_Count_Manage__c |
Number |
Stores the number of pages consumed while managing generated document. |
LastModifiedById |
Lookup |
Lookup to the user who last edited the record. Includes the date and time of the last edit. |
CreatedById |
Lookup |
Lookup to the user who created the record. Includes the creation date and time. |
So what do all these fields allow us to achieve? They offer more options when generating documents and allow the user to completely customize the document being generated to achieve the exact result the user wants. For example, the Document Format field allows the user to choose between one or more ways the resulting document will be saved, and the Save As field allows them to further decide where the created document will reside: on the Salesforce platform as a File or Attachment or just on Google Drive of the organization.
While creating the Document Request you are not limited by the options you have in the Button Configuration of the selected Document Template. For example, if you have the Format option only as PDF in the Button Configuration, in the Document Request you will be able to choose from all possible options we have in Maven Documents.
Along with customization, the fields also offer some neat extra capabilities:
In the Document Title field, you can write down the name, that the generated file will have. It could be different from the name of the template.
If you leave the field empty, the generated file has the same name as the used template document.
Using these 4 fields, you can tailor access to the generated file according to your preferences and security policies.
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 |
This feature is available for PDF and DOCX file formats of the DOCX Document Template Saved as OneDrive.
If you would like to store some extra JSON metadata inside the generated file, you can use the Embedded Data field for this purpose. Simply place the JSON snippet inside the text frame of the field and save the Document Request.
Once the request is processed, the document is generated. Now, you can download this file to your device and open it with a specified app. Check the Document Properties and find the embedded metadata in place.
This feature is available for PDF and DOCX file formats of the DOCX Document Template.
In the PDF Conformance level field you can enter the value that stands for the needed level.
These levels set clear rules and standards for PDF files to make sure they are self-contained, work on any device, and are good for long-term storage. These rules cover things like fonts, colors, metadata, transparency, and other parts of creating and storing PDFs. The aim is to ensure that PDFs look the same no matter what system or software is used to open them.
If you leave the field untouched, the PDFA3a level will be applied by default.
The PDF Version field defines the version of the PDF specification to which the PDF Document conforms. In this field, you can put the value that represents the needed version.
If you leave the field untouched, the PDF_1_7 version will be applied by default.
This feature is available for PDF file formats of the DOCX Document Template.
Maven Documents provides you the ability to translate chosen elements of the template. You can achieve it with the Template Labels feature. More information on how to use it can be found on the corresponding page.
In the Language field on a Document Request, you can determine the needed language value from the Template Label record. Once the Request is completed, the generated file will have the translation of labels defined inside to the selected language.
The Locale field lets you display such data as currency, numbers, date, and time in the generated document in the format of the desired country's locale. If this field is not specified, the current user's locale will be used. Here you can find more information on how to use the field. In majority of cases user's locale should be used when generating the document, so this field can be left empty.
If you would like to put the generated document into the specific folder on Drive you can define the path in the Folder Path field. You can check the Document Templates page to get more information on how to fulfill the field according to different template types.
In this field, you can use the ID of the needed folder on Drive or manually write the way to the destination folder with string values. You can also use merge fields to name the folders. In that case, after the generation process is over, the folder on OneDrive will have the name of the value from the used merge field.
The ID of the folder can only be used for Google Templates and only at the beginning of the path. If you put it in the second place or further, the value is recognized as a string and you'll get the folder named as the ID.
If the field is left empty, the generated file appears in the same folder where the template document is located.
Currently, fields show information about the generated DOCX Document Templates.
If you need information about the number of pages in the generated document, you can find it in the Page Count Generate field. This is the information field, so it can't be edited. The value appears automatically once the Document Request is completed.
After generating the initial document, you can preview it using the After Merge Preview option. This previewed document is saved as a DOCX file on OneDrive. If you are going to store it on Salesforce as a File or Attachment, or on OneDrive as a PDF, additional actions are required. The number of pages used in these additional actions is recorded in the Page Count Manage field. Any changes in the number of pages during the preview will also be updated in this field.
When the After Merge Preview is used, the final number of pages in the generated document is reflected in the Page Count Manage field. However, the Page Count Generate field still shows the number of pages in the document that appeared in the After Merge Preview in the first place.
There is a limit for Google: the maximum number of Document Requests that are being processed in parallel in the last 15 minutes is 2 for Sandbox Orgs and 10 for Production Orgs.
These values count towards the limit:
For example, if you currently have 9 Document Request records that are in Processing status, and 1 in New status, you would have to wait until some of your documents have finished generating or for 15 minutes. Only after one of these conditions is completed, you can create a new request.
There is a way to create more document requests than is the limit. To do that, you can use the Batch feature from the Maven Documents Settings tab.
After running the batch, it is possible to stop it by clicking the Stop Batch button, which only becomes available while the generation process is running. The creation process may take a while after which generated documents will be available in the attachments section of every record the document was generated.
As you've noticed, there's also the Action Requests related list on the corresponding Document Request. The list shows executed Actions that were created on the selected Document Solution or were added during the process of invoking the Document Request. The list also shows the current status of these Actions. The order in which the Action Requests appear in the list is determined by the Order Of Execution field on the Action object.
The Generate Document action is executed first, despite the set order. The only exception is when you are inserting Action Requests with the code, where you can arrange the order differently.
After clicking on each Action Request, the associated record opens displaying the corresponding data.
Fields between the Details and System Information sections will differ, depending on the selected Action. In the Input section, you'll see the values that you've put in when creating the action, and the Output section will show you the result values of the needed action.
In our example you can see the Generate Document action which is always created by default when the document generation process takes place:
There are two ways of creating the Action Request:
Since using code is too technical and too advanced, let's focus on the first option.
In the beginning, it is important to notice that the number of Action Requests connected to any particular Document Request depends on the number of actions created on the Document Solution. Let's say that the Document Solution that is connected to the Document Request, has Delete Google File and Email Autosend actions created.
It means there will be three Action Requests related to the created Document Request:
In the Actions section, we mentioned the Mandatory Action checkbox. This checkbox affects the overall status of the Document Request. If you have multiple actions on the Document Solution and one of them, marked as Mandatory, fails during document generation, the entire Document Request will be marked as an Error. Actions that were supposed to come after the failed one will be Cancelled, but those executed before will be marked as Completed.
If the Mandatory Action checkbox is not marked, a failure in that specific action won't impact the Document Request status or the statuses of the subsequent Action Requests.