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.
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 |
---|---|---|
Record_Id__c |
Text |
Id of the record that document generation started from |
Status__c |
New , Processing , Completed , Error , Cancelled |
Current status of Document Request. |
Document |
Lookup |
Lookup to Document Template that this Document Request is using |
Document |
Lookup |
Lookup to Document Solution that this Document Request is using |
Document |
PDF , DOCX , Google Doc , Google Sheet , XSLX , CSV |
What (file) format should be the result of the document generation action |
Save |
File , Attachment , Google Drive File |
How should the document be saved on your Salesforce Org |
Processing |
Queue , Batch , Synchronously |
Processing Type |
Error |
Text |
Descriptive text containing an error message if such an error occurred |
Reuse_File |
Boolean |
If checked, 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 |
External |
Text |
Id of the generated document in the external system (e.g. Google Drive) |
External |
Text |
Name of the generated document in the external system |
File |
Text |
Salesforce File or Attachment Id |
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 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:
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 actually a way to create more document requests than is the limit. For 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.
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 in the process of generation.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 newely 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.
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.