You are here:
Contract Generation in Batch Mode
Contract generation can handle up to approximately 100 line items with good performance. To create documents with more than 100 line items, generate the contract in batch mode. Batch mode is available for object- or JSON-based Vlocity Web Templates, provided a Custom Section is used to fetch and format lines. This topic tells you how to create the custom Apex class and template required for batch generation, and how to batch-generate topics.
You cannot use batch mode with Microsoft Word or Microsoft PowerPoint templates.
Writing a Custom Class for Batch Mode
To implement batch mode, you must define a custom Apex class that extends DocTemplateMappingAbstractClass. The class must implement the methods described below.
You can use the Batch Generation example class to copy and paste as the basis for your custom class.
The class must include the following methods:
-
public override List<Object> getNextSet(String sectionName): Generates the HTML table content required in each contract document section. The repeatingMapList holds the HTML content for each line item. Add the tableEndTag at the end of the batch job for the last line item. -
public override Boolean hasNextSet(String sectionName): Check whether current processing is required. The hasNextStep() method is executed before getNextSet(). To ensure that all records are processed, this method must return true when there are additional records and false when all records have been processed. -
public override Integer getStartIndex(): Returns the section sequence. -
public override Integer getBatchDataCount(String sectionName): Returns the line item count.
Generating a Contract from a Template Using Batch Mode
Generate contracts from a template more efficiently with batch mode.
-
On the Contract record detail page, on the Contract Documents Visualforce page, click Generate.
-
From the Select a Document Template picklist, select a contract document template that includes the custom section you defined above.
-
Click Start Batch Process. The contract is generated from the template.
-
To download the contract, click Download Word.
-
To check in the contract, click Check In.
- Creating a Custom Section in a Contract Template
To create a custom section in a contract template that you intend to generate using batch mode, edit the template using the Document Template Designer.

