A5 Documents is designed to run seamlessly with Salesforce automation tools. The app contains a custom object called a Document Request. You create a record in Document Request, then the app picks up these records and processes them. The method you use to create the Document Request record is the automation tool that you select. Choose which automation tool you will use: Process Builder, Flow, or Apex. If you are not sure which automation tool to use read this article by Salesforce. Using Process Builder is the easiest and most recommended way to automate document generation.
- Configure your Document Action for Automation
- Automation with Process Builder
- Automation with Apex or Flow
- Automation with Professional Edition
- Documentation Speed/Limits
Configure your Document Action for Automation
Follow the same steps to Create a Document Action as you did when you configured a custom button.
If you would like to configure the Email section for Automation, set the Email Action field to “Autosend” (Automation will not work if it is set to”Preview”). After making any changes to the Email section, copy the updated document action code and paste into your related custom button.
Automation with Process Builder
If you are using automation with Process Builder to generate Document Requests, please note following details:
- If you have not used Process Builder before, learn more about it here. With Process Builder you can configure your process to complete a simple action, or complete multiple actions at once, including time based updates, field update, flow execution and more. It’s a very powerful and user-friendly tool that allows you to create and configure most of the processes without writing any code.
- In process builder you will create the criteria that will execute the action to generate a document.
- Then you will create the action that will Create a Record.
- Select the Record Type as “Document Request”.
- For the field values:
- Document Action and Record Id, but you can also add an Error Message field, in case document generation ends with an error.
- For Document Action Field select Type “ID” from drop down. For the Value it must be set as the Salesforce Record ID of the Document Action you are wanting to have executed (e.g., a020G00000vCKbWQAW). If you navigate in another window to the Document Action record you previously configured you can copy the salesforce id in the url in your browser.
- For Record Id Field select Type “Field Reference” from drop down. For the Value, click to then select the Id field of the object you are executing the process builder from. This will merge the salesforce record id of the record this document is based on into this field.
- Optionally you can click Add Row and set Error Field to be any text field you wish on your object. If you are creating a process on a custom object we recommend that you previously create a text field called something like Document Generation Error and then map it in this step. Error field in Process Builder needs to be the API name of the field, e.g. Doc_Gen_Error__c. It would be a string value as shown in screenshot below. Although the error field is not required, it can be helpful in case something prevents Document Action to execute, so you can see what the error is and fix it.
- Process Builder will create a new Document Request record for each document that is created. Using Document Requests allows you to track the status of each generated document. If the action fails, there will be an error populated on the Document Request record that is related to the record that failed. It will also be populated in the error field you specified on the object if you specified one.
- Under the Conditions section, there is a drop-down menu, “Advanced”. There is a checkbox field, “Do you want to execute the actions only when specified changes are made to the record?” Most commonly this box is check to “True”.
- Activate the process builder and test by making a record meet the criteria specified in your process builder. The first thing that you can check if it is working is a Document Request record would exist with a pending status. Navigate to all tabs and go to Document Request tab and select the view All to see the records.
- A5 Documents will automatically process any Document Request records created within a minute and typically right away. If you are generating many Document Requests at once there will then be many Document Request records pending and the app will process them one at a time. Most documents take an average of 10 seconds to generate. So the speed will be one document every 10 seconds. This will vary depending on your template and what you are merging. Another factor for speed is overall Salesforce queues and processing throttling.
Automation with Apex or Flow
You can use custom Apex code or Flows with any logic or process to create a Document Request record if it is beyond Process Builder capabilities.
You just need to create/insert a Document Request record and set the values for the fields Document Action, Record Id, and optionally Error Field using the same logic describe in the process builder instructions above.
Automation with Professional Edition
As you may know, Professional Edition is limited in automation possibilities because, unlike Enterprise Edition, it limits access to Apex, Process Builder, and Workflows. While Professional Edition gives you the ability to create 5 Workflows/Process Builders, access to Apex is completely restricted. Also, our parallel processing feature is not available in Professional Edition.
- Automation happens in future methods. This means that document generation runs asynchronously so it might be a few seconds late until you can actually see it completed. If you are testing automation after you trigger it, give it a minute and then refresh your page to see if it’s completed.
Document Generation Speed/Limits
To start generating documents automatically, all you need to do is create a Document Request record(s) per the instructions above and a document generating job will be scheduled to run in one minute. You can create Document Request records manually, or using process builder or a flow, or using Apex as mentioned above. All of these will run the job.
This way, the app can generate one document approximately every 5-10 seconds. Document generation speed depends on the template complexity, and fields and objects merged. It can also vary depending on the server speed and network latency of Salesforce and Google Drive at a time. Also, there should be no hidden formatting in the google doc that could be left over from a copy/paste or a word doc import. If there is a concern or desire to make sure the template is very clean, it is best to create a new google doc and copy the text into it, or type in the new text, instead of importing a word doc and converting it to google doc. In most cases this is fine, but if speed becomes a concern, this should also be checked.
Faster document generating can be achieved by enabling parallel processing feature which would be useful if you are generating many documents at once in a batch and want it to generate faster. To have it enabled, you can make a request by contacting A5 support, and we must understand your business needs in order to enable it. This way the speed can be increased up to 7,500 documents/hour.
NOTE: Parallel processing is not available in Professional Edition because it uses Platform Events.
If your document request records are getting stuck in “New” status and not processing, please review this article for more detail.