Skip to main content
Note: Box Doc Gen only supports the ability to leverage English template tags when creating and leveraging Box Doc Gen templates. We recommend that customers test and review that Box Doc Gen supports their desired language requirements when generating documents.
With the help of Box Doc Gen template tags, you can easily create and author document templates used to dynamically generate custom documents instantly. When a document generation process takes place, the pre-configured Box Doc Gen template automatically identifies the Box Doc Gen tags within the template, matches the tags with the fields in the JSON input data, and replaces the tags with the appropriate data to dynamically generate a document. Template tags can be used to dynamically generate text, images, tables, lists, blocks of content, or even Box Sign tags.

Text tags

A text tag is any data field of type, string, number, or date. For example, the following fields can become text tags:
  1. id
  2. date
  3. customerId
  4. customerName
  5. currency
  6. amount
{
  "invoice":{
    "id": "Inv1203",
    "date": "13-03-2023",
    "customerId": "90158",
    "customerName": "Acme Inc",
    "currency": "$",
    "amount": 5060.50
  }
}

In the output document generated, all the template tags will be replaced with the input data.
Note: Box Doc Gen tags do not support spaces or hyphens between key words in the tag. For example, {{first name}} or {{first-name}} are not supported.
Document templateOutput document

Invoice

Invoice id: {{invoice.id}}

Invoice date: {{invoice.date}}


Customer details:
Customer id: {{invoice.customerId}}
Customer name: {{invoice.customerName}}


Amount Payable:

{{invoice.currency}}{{invoice.amount}}

Invoice

Invoice id: Inv1203

Invoice date: 13-03-2023


Customer details:
Customer id: 90158
Customer name: Acme Inc


Amount Payable:

$5060.50

Optional tags

Input formatInput dataOutput data
{{invoice.customerName}}-{{invoice.customerName}}
{{invoice.customerName :: optional}}-

Default values

Input formatInput dataOutput data
{{invoice.customerName}}-{{invoice.customerName}}
{{invoice.customerName :: default(“Box Inc”)}}-Box Inc

Formatting text tags

Input formatInput dataOutput dataSupported via scriptSupported via Add-in
{{invoice.customerName :: uppercase}}Acme IncACME INCYesNo
{{invoice.customerName :: lowercase}}Acme Incacme incYesNo
{{invoice.date :: format( “dd-mm-yyyy”) }}13-03-202313-03-2023YesNo
{{invoice.date :: format(“mm-dd-yyyy”) }}13-03-202303-13-2023YesNo
{{invoice.date :: format(“dd-mmm-yy”) }}13-03-202313-Mar-22YesNo
{{invoice.id :: format(“xxx-xxxx”) }}Inv1203Inv-1203YesNo
{{invoice.amount :: format(“EU-Number”) }}300000300.000YesNo
{{invoice.amount :: format(“US-Number”) }}300000300,000YesNo

Rich text

Box Doc Gen allows you to generate documents with rich text. If the input JSON data contains HTML tags such as bold, italic, underline, line breaks, paragraphs, anchors, or images, Doc Gen automatically interprets them as rich text and applies the relevant formatting.
HTML TagsJSON dataOutput
Bold{ "company": "<b>Acme Inc.</b> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<b> 999-999-9999</b>" }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Italic{ "company": "<i>Acme Inc.</i> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<i> 999-999-9999</i>" }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Underline{ "company": "<u>Acme Inc.</u> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<u> 999-999-9999</u>" }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Bold, Italic and Underline{ "company": "<b><i><u>Acme Inc.</u></i></b>A fictional company that features prominently in the Road Runner show as a running gag. Phone:<b><i><u> 999-999-9999</u></i></b>" }Acme Inc*.* A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Strong{ "company": "<strong>Acme Inc.</strong> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<strong> 999-999-9999</strong>" }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Span{ "company": "<span>Acme Inc.</span> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<span> 999-999-9999</span>" }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Emphasized{ "company": "<em>Acme Inc.</em> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<em> 999-999-9999</em>" }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Line breaks{ "company": "<b>Acme Inc.</b>  \n A fictional company that features prominently in the Road Runner show as a running gag. \n Phone:<b> 999-999-9999</b>" }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Paragraphs{ "company": "<b>Acme Inc.</b>  <p> A fictional company that features prominently in the Road Runner show as a running gag. </p>  <p> Phone:<b> 999-999-9999</b>"</p> }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Ordered list
  1. Blue
  2. Green
  3. Red
Unordered list
  • Blue
  • Green
  • Red

Image tags

An image tag can be used to dynamically add and render images. Box Doc Gen supports images in base64 format. To add image tags to your Box Doc Gen template:
  1. Insert a placeholder image, position it, and resize it to your needs
  2. Add a $image-path variable to the image under Alt text. Under the image path, refer to the variable in the JSON data that holds your image in base64.
    For the sample JSON code below, we refer to contract.logo to have the base64:
{ 
"image-path": "contract.logo”, 
"alt-text": "Alt text" 
}
During the document generation process, Box Doc Gen replaces the placeholder image with the base64 value associated with the key identified.
{
  "contract":{
    "customerId": "1203",
    "date": "18-08-2023",
    "country": "UK",
    "customerName": "Example Corporation",
    "logo": "iVBORw0KGgoAAAANSUhEUgAAAHgAAABACAMAAADmk0MgAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAC31BMVEUAAAAXoughpvAhqO8jp/AjqfIhpu4ip/Aip+9Av/8jpvAipvAgn/8ipO4hp/AhpfEip/Agp/EiqPAkpvIip+8ipu4hp+8hqe8iqPEkp+8ipvEjqe8jqPAip/AhpvAhpvAiqPAhqPAipvAjpvEipfEiqPIzmf8hpe8jpfAiqu4rquompvIjpvAipvEhqPEip/AjqPAhp/AgpfEmpfAA//8ipvAipu8jp/Ahp/Ehp/Aip/Aip/Ahp/Ahp+8hpu4gn+8kqO8ip/Ahp/Ahp/Aip+8Aqv8jqPEip/Eip/Aip/AiqPAjqO8nsesip/Aip/AfqPMiqu4ip+8ip/Agp+8ip+8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jBUMDM6MTg6MDUrMDA6MDDzlDIjAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDI0LTA3LTIwVDAzOjE4OjA1KzAwOjAwgsmKnwAAAABJRU5ErkJggg==",
    "customerAddress":{
      "street": "Example street",
      "city": "Example city",
      "zip": "EX-456"
    }
  }
}

Document Template

Output

Box Doc Gen replaces the placeholder image with the base64 value associated with the key identified. The output on the generated document will display as follows:

Table tags

An array from the input data can be used to generate and dynamically format a table. In the following example:
  • items is an array that can be rendered as a dynamic table.
  • id, name, quantity, price, amount are the variables within the array that can be rendered as individual columns to the dynamic table.
{
  "invoice":{
    "number": "Inv1203",
    "date": "13-03-2023",
    "customerId": "90158",
    "currency": "$",
    "amount": 5060.50,
    "items": [
      {
        "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.50
      }
    ]
  }
}

Document Template

The document template with inserted tags will look as follows:
IdNameQtyPrice
{{tablerow item in invoice.items}}
{{item.id}}{{item.name}}{{item.quantity}}{{item.price}}
{{endtablerow}}

Output

Box Doc Gen automatically identifies the table tags added to the document template, matches them with the fields in the input JSON data, and performs a few iterations to generate a complete table for the input data. The output table on the generated document will look as follows:
IdNameQtyPrice
1A4 Papers10029
2Ink  Cartridge4039
3Adhesive tape2030

List tags

An array from the input data can be used to dynamically generate an ordered or unordered list. In the following example:
  • items is an array that can be rendered as a dynamic list.
  • id, name, quantity, price, amount are the variables within the array that can be rendered as a repetitive field in the list.
{
  "invoice":{
    "number": "Inv1203",
    "date": "13-03-2023",
    "customerId": "90158",
    "currency": "$",
    "amount": 5060.50,
    "items": [
      {
        "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.50
      }
    ]
  }
 }

The input data can be used to generate different types of lists:
Use caseDocument templateOutput document
Adding a bullet list

List of products:

{{ for item in invoice.items }}
  • {{item.name}}
{{ endfor }}
  • A4 Papers
  • Ink cartridge
  • Adhesive tape
Adding a bullet list with one or more variables

List of products:

{{ for item in invoice.items }}

  • {{item.name}}, {{item.quantity}}

{{ endfor }}

  • A4 Papers, 100
  • Ink cartridge, 40
  • Adhesive tape, 20
Adding a squared bullet list with one or more variables

List of products:

{{ for item in invoice.items }}

  • {{item.name}}, {{item.quantity}}

{{ endfor }}

  • A4 Papers, 100
  • Ink cartridge, 40
  • Adhesive tape, 20
Adding a white bullet list with one or more variables

List of products:

{{ for item in invoice.items }}

  • {{item.name}}, {{item.quantity}}

{{ endfor }}

List of products:

  • A4 Papers, 100
  • Ink cartridge, 40
  • Adhesive tape, 20
Adding a numbered list with one or more variables

List of products:

{{ for item in invoice.items }}

  1. {{item.name}}, {{item.quantity}}

{{ endfor }}

  1. A4 Papers, 100
  2. Ink cartridge, 40
  3. Adhesive tape, 20
Adding a roman numbered list with one or more variables

List of products:

{{ for item in invoice.items }}

  1. {{item.name}}, {{item.quantity}}

{{ endfor }}

  1. A4 Papers, 100
  2. Ink cartridge, 40
  3. Adhesive tape, 20
Adding an alphabetical list with one or more variables

List of products:

{{ for item in invoice.items }}

  1. {{item.name}}, {{item.quantity}}

{{ endfor }}

  1. A4 Papers, 100
  2. Ink cartridge, 40
  3. Adhesive tape, 20

Formatting lists

Box Doc Gen templates support a wide range of custom codes that you can use in the document template. Taking the following JSON input data as an example, you can introduce different separators and delimiters.
{
  "items": ["A4 Papers", "Ink  cartridge", "Adhesive tape"]
}

Type of listDocument templateOutput document
List - with comma separator{{ items :: delimiter(“,”)}}A4 Papers, Ink cartridge, Adhesive tape
List - with semicolon separator{{ items :: delimiter(“;”)}}A4 Papers; Ink cartridge; and Adhesive tape
List - with customer separator{{ items :: delimiter(“~”)}}A4 Papers~ Ink cartridge~ Adhesive tape
List - with Comma and last delimiter{{ items :: delimiter(“,”) , lastdelimiter (“, and”)}}A4 Papers, Ink cartridge, and Adhesive tape
List - with semicolon and last delimiter{{ items :: delimiter(“;”) , lastdelimiter (“; and”)}}A4 Papers; Ink cartridge; and Adhesive tape
List - with custom separator and last delimiter{{ itemsdelimiter(“~”)}}, lastdelimiter (“~ and”)}}A4 Papers~ Ink cartridge~ and Adhesive tape

Conditions

You can use conditions to add input to the output document. The Box Doc Gen Template Creator add-in can help you define these conditions within the document template.

Supported conditions and operators

Tag typeConditions supportedOperators supported to chain conditions
String==(is equal to), !=(is not equal to), isPresentAND, OR
DateisPresentAND, OR
Number<, >, ==, !=, >=, <=AND, OR
The following JSON serves as input for defining conditions for the Box Doc Gen template.
{
  "invoice":{
    "number": "Inv1203",
    "date": "13-03-2023",
    "customerId": "90158",
    "currency": "$",
    "amount": 5060.50,
    "paymentMethod": "Cheque",
    "paymentTerms": "Net60",
    "deliveryDate": "23-03-2023",
    "items": [
      {
        "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.50
      }
    ]
  }
 }

Use caseDocument templateOutput document
Introducing content based on payment method and payment terms

Payment terms:

{{ if invoice.paymentMethod == “Online Transfer” AND invoice.paymentTerms == “Net30” }} 

  • The invoice must be paid within 30 calendar days of the invoice date. 
  • The payment reference should contain the invoice number as reference.

{{ elseif invoice.paymentMethod == “Cheque” AND invoice.paymentTerms == “Net60” }} 

  • The invoice must be paid within 60 calendar days of the invoice date.
  • The payment reference should contain the invoice number as reference. 
  • CHECK MADE PAYABLE TO: Box Inc, 900 Jefferson Ave, Redwood City, CA 94063, United States.

{{else}}

  • The invoice must be paid must pay within 7 calendar days of the invoice date.

{{endif}}

  • The invoice must be paid within 60 calendar days of the invoice date.
  • The payment reference should contain the invoice number as reference. 
  • CHECK MADE PAYABLE TO: Box Inc, 900 Jefferson Ave, Redwood City, CA 94063, United States.
Adding processing fees based on invoice amount, and payment method

Processing fees:

{{ if invoice.amount >  1000 AND invoice.amount < 5000 AND invoice.paymentMethod == “Cheque” }} 

  • There will be an additional 1% processing fee that will be added to your account.
  • The processing fee will be included to your next invoice.

{{ elseif invoice.amount > 5000 AND invoice.paymentMethod == “Cheque”}} 

  • The invoice can be paid via check or online transfer without any added processing fees.

{{else}}

  • The invoice must be paid within 7 calendar days of the invoice date. 

{{endif}}

  • The invoice can be paid via check or online transfer without any added processing fees.
Adding delivery terms based on delivery date on invoice

Delivery terms:

{{ if invoice.deliveryDate isPresent }} 

  • Your order shall be delivered on {{ invoice.deliveryDate}}.
  • Orders delivered can be returned within 10 days of delivery.

{{else}}

  • Your order shall be delivered within the next 7 days.
  • Orders delivered can be returned within 10 days from the date of delivery.
  • Your order will be delivered on 23-03-2023.
  • Orders delivered can be returned within 10 days of delivery.

Conditions with tables

Doc Gen allows you to conditionally render any content including tables, images, and so on. {{ if invoice.customerId isPresent }}
IdNameQtyPrice
{{tablerow item in invoice.items}}
{{item.id}}{{item.name}}{{item.quantity}}{{item.price}}
{{endtablerow}}
{{ endif }}

Conditions inside tables

Doc Gen allows you to conditionally render content with a column in a table. Examples
IdNameQtyPrice
{{ tablerow item in invoice.items }}
{{ item.id}}{{ item.name}}{{ item.quantity}}{{ if item.price isPresent}}{{item.price}}{{ else }}-{{ endif }}
{{ endtablerow }}

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.
Sample code calculations include:
  • Invoice: Determining the net invoice amount from individual line items.
    Example: Sum (Individual Line item amounts in the invoice)
  • Purchase order: Capping the maximum sourcing amount.
    Example: 5% * Net Order Value
  • Sales contracts: Defining penalty on SLA breach.
    Example: 10% * Total Sales Value
Supported operations
Arithmetic operationsAggregation operations
%Percent
+SUM
*AVERAGE
-COUNT
The following JSON serves as input for adding calculations to the document template.
{
  "invoice":{
    "number": "Inv1203",
    "invoiceDate": "13-03-2023, 12:10 PM",
    "deliveryDate": "23-03-2023",
    "customerId": "90158",
    "currency": "$",
    "taxRate": 3,
    "taxAmount": 151.8,
    "shippingCharge": 15,
    "grossAmount": 5060,
    "penaltyRate": 10,
    "billCap": 25,
    "items": [
      {
        "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
      }
    ]
  }
}

Examples:
Use caseDocument templateOutput document

To calculate net amount from the given Gross Amount and Tax Amount 

Arithmetic calculation

Net Amount:
{{ invoice.grossAmount + invoice.taxAmount}}

Net Amount:
5211,8

Annotation:
5060 (grossAmount) + 151.8 (taxAmount)

To calculate net amount from the given Gross Amount, Tax Rate and Shipping Charge

Arithmetic calculation

Net Amount:
{{ invoice.grossAmount + invoice.taxAmount + invoice.shippingCharge}}

Net Amount:
5226.8

Annotation:
5060 (grossAmount) + 151.8 (taxAmount) + 15 (shippingCharge)

To calculate tax amount from the given Tax Rate and Gross Amount

Arithmetic calculation

Tax Amount:
{{ invoice.taxRate % * invoice.grossAmount}}

Tax Amount:
151.8

Annotation:
3% (taxRate)  * 5060 (grossAmount)

To calculate gross amount from individual line item amounts

Aggregation calculation

Gross Amount:
{{ $sum(invoice.items.amount) }}

Gross Amount:
5060

Annotation:
Sum (2900+1560+600)

To calculate number of line items

Count calculation

Count:
{{ $count(invoice.items.amount) }}
Count:
3
To calculate average of line itemsAverage Amount:
{{ $average(invoice.items.amount) }}
Average Amount:
1686.66

To calculate net amount from the given Line Item Amount, and Tax Rate 

Arithmetic + Aggregation calculation

Net Amount:
{{ $sum(invoice.items.amount) + invoice.taxRate % * $sum(invoice.items.amount)}}

Net Amount:
5211,8

Annotation:
Sum (2900+1560+600) +
3% * Sum (2900+1560+600)

Box Sign template tags

Box Sign template tags can be added to the Box Doc Gen template for the output document created via Box Box Doc Gen to be sent for e-signature. Box Doc Gen supports Box Sign template tags. The table below lists the tags available in the Box Doc Gen Template Creator add-in and the tagging script.
FieldBox Sign’s template codeSupported
via tagging script
Supported
via add-in
Text field[[t|0]]YesYes
Date field[[d|0]]YesYes
Checkbox field[[c|0]]YesYes
Signature field[[s|0]]YesYes
Stamp field type[[st|0]]YesYes
Initials field type[[i|0]]YesYes
Name field type[[n|0]]YesYes
First name field type[[fn|0]]YesYes
Last name field type[[ln|0]]YesYes
Company field type[[co|0]]YesYes
Email field type[[e|0]]YesYes
Title field type[[ti|0]]YesYes
For an attachment field type[[a|0]]YesYes