After successfully generating the Box Doc Gen template tags from JSON data or Box Doc Gen template tags in the Box Doc Gen Template Creator add-in, you can insert those tags in your document.
The Box Doc Gen template tags can be used to dynamically insert text, images, tables, lists, calculations, conditional logic, and more.
The sample JSON data below contains fields that can be used as tags within your template.
{
"order": {
"id": "Inv1203",
"date": "18-08-2023",
"customerName": "Example Corporation",
"currency": "$",
"amount": 5060.5,
"billingAddress": {
"street": "Example street",
"city": "Example city",
"zip": "EX-456"
},
"products":
{
"id": 1,
"name": "A4 Papers",
"quantity": 100,
"price": 29,
"amount": 2900
},
{
"id": 2,
"name": "Ink Cartridge",
"quantity": 40,
"price": 39,
"amount": 1560
},
{
"id": 3,
"name": "Adhesive tape",
"quantity": 20,
"price": 30,
"amount": 600.5
}
]
}
}
Text tags
Text tags types include: Text, Date, or Number.
To insert a Text tag:
- In the Box Doc Gen Template Creator add-in, go to Document Tags > Text Tags.
- In the document, place the cursor in the area where you want to insert a text tag (for example, order.id).
- Click the text tag.
This action inserts the {{order.id}} text tag in the specified area of the document. For more template tag examples, see Template tags reference and examples.
Image tags
Image tags can be added to the Box Doc Gen template, and can be dynamically auto-populated by Box Doc Gen during the document generation process. A base64-encoded string from JSON data is automatically recognized by the Box Doc Gen Template Creator add-in as an image and applies the image to the document.
To insert an Image tag:
- In the Box Doc Gen Template Creator add-in, go to Document Tags > Image Tags.
- In the document, place the cursor in the area where you want to insert an Image tag.
- Double-click the image tag to insert it.
This action inserts a placeholder image, which can be dynamically replaced by the input data from the Box Doc Gen API, workflows, or any other upstream systems.
Note: The dimensions, and alignments of the placeholder image can be altered using Microsoft Word functions. These properties are retained in the output document. Alternatively, before inserting the image, you can define properties such as width, height, and alt text.
Tables and lists
An array from the input data can be used to dynamically build a table or a list. Any data such as invoice items, order lists or sales orders, can be dynamically transcribed in a table.
For example:
- Products is an array that can be rendered as a dynamic table or a dynamic list.
- Id, name, quantity, price, amount are the variables within the array that can be rendered as individual columns to the dynamic table.
Inserting a table
- In the Box Doc Gen Template Creator add-in, go to Tables & Iterations > Tables.
- In the Table Record section, view the arrays that are included in the JSON data (for example, products).
- Select the array that will provide the table data.
- For the Column Record, select the fields that will serve as columns (for example, id, name, quantity, and price).
- Click Insert Table.
This action inserts a table with the following dynamic fields: id, name, quantity, and price.
Inserting a list
- In the Box Doc Gen Template Creator add-in, go to Tables & Iterations > Lists.
- Under Format, specify if the list should have Bullets, Numbers or No formatting. If you select Bullets or Numbers, you can additionally select Style for these list types.
- Under List Record, select the array that holds the items to populate the list.
- Under Fields, select the values that will serve as list items.
- Click Insert List.
For more tag examples, see Template tags reference and examples.
Logic
Conditions
Conditional logic allows you to show or hide content based on data or conditions that are achieved within the document generation process. This can be used to include or exclude sections of a document.
To insert a condition:
- In the Box Doc Gen Template Creator add-in, go to Logic > Conditions.
- Under the IF statement, create a desired condition using Field and Value (for example, if the country code is US).
- You can add more conditions using AND or OR operators.
- To add another statement, select ther ELSE IF operator and add further conditions.
- Use ELSE for conditions that do not match IF and ELSEIF.
Calculations
Box Doc Gen templates support dynamic calculations. You can either write the computation code to the tagging language manually, or use the Box Doc Gen Template Creator add-in.
Examples:
- Determining the net invoice amount from individual line items in invoices: Sum (Individual Line item amounts in the invoice)
- Capping the maximum sourcing amount: 5% * Net Order Value
To insert a calculation:
- In the Box Doc Gen Template Creator add-in, go to Logic > Calculations.
- Under Field, select the tag you want to perform the arithmetic aggregation operations.
- Select the operation you want to perform between the first field and the next.
- Select the next tag.
- To perform an aggregation operation, select the fx (function) drop-down menu for a specific tag and select an aggregation operation.
- As you build the calculations, the preview section displays a quick preview of the expression that you composed.
- To insert the expression, click Insert Calculation.
For more tag examples, see Template tags reference and examples.
Box Sign tags
You can add Box Sign template tags to the Box Doc Gen template if you want to send the generated document for e-signature or approval.
To insert Box Sign template tags:
- In the Box Doc Gen Template Creator add-in, go to Box Sign tags.
- Select the Number of Recipients required to sign or approve the final document generated from the Box Doc Gen template.
- You can insert the Box Sign template tag that is required for each recipient who needs to sign or approve the generated document:
- When selecting the Box Sign template tags, you can also specify if the field is mandatory or optional for the selected recipient to fill or sign.
- You can change the size of the text, date, and signature fields vertically by adjusting the size of the font and horizontally by adding spaces between the curly brackets.
- For best results, insert the tags into a table or modify the tags to have a different text style than the body of the document.
- Once you have inserted all the necessary Box Sign template tags into the template, change the font color of the tags to white to ensure they are not overlaid on top of the generated Box Sign fields in the final document, and are only replaced by signature fields.
Additional template tag examples
For more tag examples, see Template tags reference and examples.