Skip to main content

Tags in DOCX documents

Y
Written by Yuliia Biletska
Updated over 2 months ago

Basic information

What are tags used for?

In airSlate, document generation tags are tools for creating dynamic, automatically generated content within documents. Tags allow you to insert data, images, tables, and other elements from external sources into your documents. This is particularly useful for streamlining workflows where multiple data inputs are required.

Use tags to:

Action

Description

Create merge fields

Automatically populate text fields with data.

Insert images

Add dynamic images based on external data.

Add tables with dynamic rows

Insert data tables with variable row counts based on conditions.

Show or hide text based on conditions

Control visibility of document sections.

Insert a list of items

Populate lists from external data.

Insert HTML content

Embed formatted HTML directly into your document.

How to Add Tags?

  • Tags in airSlate DOCX templates are enclosed in figure brackets - {{TagName}}.

Example:

Dear {{ClientName}},

We are writing to inform you that your contract, starting on {{StartDate}}, has been approved.

  • You can use the Tag Generator in the airSlate online editor to automatically create merge tag syntax. Once generated, copy and paste the tag into your document.

Note: Tags can be named anything you like, as long as they are descriptive and easy to identify during field mapping in bot settings.

How to populate tags?

To populate tags with data, pre-fill bots pull content from external sources such as Salesforce, MS Dynamics 365, Google Sheets, MySQL, and more. This allows you to use multiple data sources to populate one document automatically.

For example, you can grab a section of data from your Salesforce records and another section from NetSuite records and generate documents containing both data sections.

Tags vary according to the data type (single lines or table rows) you need to populate.

  • When populating single lines, the field tags should look as follows:

{{Account_name}} allows using numbers and underscores.

  • When populating table rows, the field tags like {{for(Product)}}{{Name}}{{endfor}} should look as follows:

{{Product[].Name}}

Types of tags

Different types of tags can be used for specific purposes. The following are the tag types, along with examples of their usage:

Type

Example

Usage

Merge tag

{{TagName}}

Use this tag to insert a merge field.

Merge tag names don't need to be unique - if you add multiple merge fields with the same name, every field will be populated with the same data. Generate merge tags via the Tag Generator in the online editor or add them manually to your documents. When the documents are generated, merge tags are pre-filled with specific data that users cannot edit.

For tag

{{for(ListName)}}

List Element Field1:

{{ListField1}}

{{endfor}}

Use this tag to insert lists or repeat elements. Its name should be unique per document. Be sure to select the Table according to the type of data you intend to pre-fill in the lists.

Table tag

{{table(tableName)}}

{{ColumnField1}}

{{ColumnField2}}

{{endtable}}

Use this tag to insert a table with a dynamic number of rows. The name of this tag should be unique per document.

IF tag: Condition depending on variable or field value

{{if(ConditionFieldName=‘Value1’)}}

Output 1

{{else(ConditionFieldName=‘Value2’)}}

Output 2

{{endif}}

Use this tag to add conditional logic to your documents. With this tag, you can show or hide paragraphs of text depending on conditions. The name of this tag should be unique per document.

{{if(ConditionFieldName=‘Value1’ && ConditionFieldName=‘Value2’)}}

Condition 1 and Condition 2

{{endif}}

Use the “and” operator && to add multiple conditions in the IF functions where all logic conditions will be met.

{{if(ConditionFieldName=‘Value1’ || ConditionFieldName=‘Value2’)}}

Condition 1 or Condition 2

{{endif}}

Use the “or” operator || to add multiple conditions in the IF functions where one of the logic conditions will be met.

{{if(Field != null)}} Field is not empty {{endif}}

Use this syntax to check whether the field value is null.

HTML tag

{{html:FieldName}}

Use this tag to insert HTML-formatted content (for example, from Salesforce Rich Text Field).

Fillable field tag

Refer to the Fillable fields section

If you don't want to drag and drop fillable fields into your document, you can use fillable field tag syntax to create fillable fields.

Image tag

{{for(Array)}}

{{imageFile(ImgField)}}

{{endfor}}

Use this tag to insert PDF/DOCX documents and images in the body of a document (for example, from Salesforce records).

Tags for columns and rows in tables

{{rowIf(ConditionName=‘Value’)}}

And

{{columnIf(ConditionName=‘Value’)}}

Conditional tags to show or hide rows/columns based on data.

Examples of using tags

Merge tags formatting functions (date, number, currency)

You can format merge tags to show date, number, or currency values.

Note: Be sure to only use ‘these’ quotation marks for strings.

  • dateFormat(DateFieldName, current_date_format, required_date_format)

{{dateFormat(Date1, ‘yyyy-MM-dd’, ‘yyyy-dd-MM’)}}

“2024-29-02”

{{dateFormat(Date2, ‘yyyy-MM-dd’, ‘EEE, d MMM yyyy’)}}

Thu, 29 Feb 2024

Use the {{$today}} function to insert a non-editable date.

  • numFormat(FieldName, string_format) – accepts a numeric value and a string with a pattern for formatting.

  • numFormat(FieldName, string_format , groupseparator_symbol, decimalseparator_symbol) is also acceptable.

{{numFormat(Field1, ‘###,###.00’)}}

16,326.20

“‘###,###.00’ adds zeros if an expression has fewer symbols after a comma than is required.”

{{numFormat(Field2, ‘###,###.##’)}}

16,326.23

‘###,###.##’ rounds the expression to two symbols after a comma if the number has more.

{{numFormat(Field3, ‘$###,###.00’)}}

$16,326.20

Adds currency symbol before the number.

Use Tag Generator to see other available date and number formats.

Table with a dynamic number of rows

The following is an example of a simple table with headers:

Name

Quantity

{{table(Products)}}

{{Name}}

{{Quantity}}

{{endtable}}

Hide an empty table header/footer (using {{h}} tag)


If tables contain any tags below headers / above footers that should be automatically hidden (in case tables have no records), add an {{h}} tag before each row with headers/footers.


To automatically hide empty tables that don't contain at least one row of data (pre-filled from tags), refer to the syntax below:

{{table(Products)}}

{{h}}Product List

{{h}}Name

Quantity

{{Name}}

{{Quantity}}

{{endtable}}

Calculate totals in a table column ($sumabove variable)

{{$sumabove}} displays the sum of numbers in cells above this tag.

{{table(Products)}}

{{h}}Name

Quantity

{{Name}}

{{Quantity}}

{{h}}Total Quantity

{{$sumabove}}

{{endtable}}

It's possible to use the result from a {{$sumabove}} tag as a parameter in functions like {{numFormat($sumabove, ‘$###,###.00’}}

Conditional Logic

You can show or hide paragraphs of text depending on conditions. To create a condition, you can use a Field or Variable (for more complex cases) with operators such as =, !=, >, <. You can use set values, field values, or variables for condition values.

The basic syntax of conditional tags is as follows:

{{if(condition)}} success action {{endif}}

{{if(condition)}} success action {{else}} fail action {{endif}}

Let's look at each piece separately:
{{if(condition1)}} success action, if condition 1 is true;

{{else(condition2)}} success action, if condition 2 is true;

{{endif}} condition is any expression, variable, or value from a function, calculation, or data source.


The example below demonstrates what the message will contain, depending on the account's city:

{{if(AccountCity=‘Boston’)}} Hello!

{{else(AccountCity=‘London’)}} God save the Queen!

{{else}} Season’s greetings! {{endif}}

Here is a summary report for your account:

{{$total=0}}

Opportunity Name

Opportunity Status

Opportunity Amount

{{table(Opportunity)}}

{{OpportunityName}}

{{OpportunityStatus}}

{{OpportunityAmount}}

{{endtable}}

{{$sumabove}}

{{$total=$sumabove}}

{{if($total<50000)}} Happy new year!

{{else($total<100000)}} Happy new year! You are eligible for a massive discount.

{{endif}}

List

  • Use the For tag syntax to display a list of items. For example, a list of patient’s visits to the doctor:

Doctor’s name: {{DoctorFullName}}

{{for(Visits)}}

Patient’s name: {{PatientFullName}}

Date of visit: {{DateofVisit}}

{{endfor}}

  • To list all the doctors and then add a list of visits to each of them, use nested For tags:

{{for(Doctors)}}

Doctor’s name: {{DoctorFullName}}

{{for(Visits)}}

Patient’s name: {{PatientFullName}}

Date of visit: {{DateofVisit}}

{{endfor}}

{{endfor}}

Variables

{{$variableName = VariableValue}} creates a variable named variableName in the document environment and assigns it a value such as VariableValue.

If a variable named variableName already exists, its value is rewritten, and the VariableValue name is assigned. You won’t be able to reach the previous value of $variableName if it’s overwritten.

{{$var = 5.48}}

Assign variable $var value 5

{{$var = ‘Harry Potter’}}

Assign variable $var the string value ‘Harry Potter’

{{$var = OpportunityName}}

Assign variable $var the value from the data source

{{$var = 5 + 47 / 2 - 34 * CompanyPrice}}

Assign variable $var the calculated value

{{$var = true}}

Assign variable $var and assign it a boolean value true

{{$var}}

Display value of $var

{{$var > 47}} {{endsWith(OpportunityName, $var)}}

Example of using variables in calculations and functions

Note: Be sure not to use the variable tags in the document's footers or headers, as they will be left empty and won't be pre-filled with any data after generating documents.

Math functions


Here, you'll find a table with tags for calculating mathematical functions, along with examples of how they work:

*

Accepts numbers:

{{4 * 5}}

{{sqrt(9) * sqrt(16)}}

{{4 * (5 + 3)}}

20

12

32

/

Accepts numbers:

{{42 / 3}}

{{(5 + 3) / (1 + 1)}}

{{sum(3, 4, 5) / 4}}

14

4

3

%

Accepts numbers. Divides the first parameter by second and returns the remainder:

{{42%2}}

{{33 % 4}}

{{34 % 4}}

0

1

2

+

Accepts two numbers or strings:

{{2 + 6 * 7}}

{{4 + abs(-2)}}

{{sqrt(17 + 8)}}

{{‘Pineapple avenue, ’ + 56}}

44

6

5

Pineapple avenue, 56

-

Accepts numbers:

{{22 - 4}}

{{17 * 3 - 8}}

{{pow(6-3, 2)}}

18

43

9

>

Accepts numbers, return booleans:

{{5 > 7}}

{{5 > 3}}

{{16 > pow(3, 2)}}

false

true

true

>=

{{6 >= 4 + 2}}

{{8 >= 4 +2}}

true

true

<

{{5 < 7}}

{{5 < 4}}

{{sqrt(25) < sqrt(4 * 9)}}

true

false

true

<=

{{3 <= 1 + 2}}

{{3 <= 4}}

{{8 <= 7}}

true

true

false

!=

Accepts any expression, returns false if expressions are equal

{{45 != 5 * 9}}

{{‘Jack’ != ‘Jackson’}}

{{2 < 5 != 16 < sqrt (49)}}

false

true

true

=,==

Accepts any expression, returns true if expressions are equal

{{45 = 5 * 9}}

{{‘Jack’ == ‘Jackson’}}

{{2 < 5 == 16 < sqrt (49)}}

{{‘Jack Jackson’ = ‘Jack ’ + ‘Jackson’}}

true

false

false

true

The only accepted unary operation is boolean NOT, which consumes and reverts a boolean. Use the ! sign to perform this operation.

For example: !(2 > 5) will return true.

Numeric functions

abs(num_value) – returns the absolute value of a number.

Examples:

  • {{abs(-3.1438)}} will return 3.1438

  • {{abs(465.5)}} will return 465.5

ceil(num_value) – rounds number up to the closest whole number that is bigger, then passes one

Examples:

  • {{ceil(3.14)}} will return 4.

  • {{ceil(-3.14)}} will return -3.

  • {{ceil(2.99)}} will return 3

floor(num_value) – rounds number down to the closest whole number that is smaller than the passed one

Examples:

  • {{floor(3.14)}} will return 3.

  • {{floor(-3.14)}} will return -4.

  • {{floor(2.99)}} will return 2

round(num_value) – rounds number to closest whole number according to math rounding rules

Examples:

  • {{round(3.14)}} will return 3.

  • {{round(-3.5)}} will return -4.

  • {{round(2.99)}} will return 3

pow(num_base, num_power) – returns num_base to the power num_power

Examples:

  • {{pow(3, 2)}} will return 9

  • {{pow(8, 3)}} will return 512

  • random() – returns a decimal number between 0 and 1, including 0 and 1. Does not require parameters.

sqrt(num_value) – return the square root of num_value.

Examples:

  • {{sqrt(273.43)}} will return 16.5357

  • {{sqrt(64)}} will return 8

  • {{sqrt(-3)}} will return NaN (not a number).

  • {{sqrt(0)}} will return 0

  • {{sqrt(3.14 / 2)}} will return 1

String functions

map (object, [key, val], [default]) – accepts a list of objects. The first value object in the list is a value that will be compared to keys. After the object, the following values are split into key-value pairs. The object is compared to keys; that value will be returned if a key matches an object. If any key does not match an object, then the number of parameters passed for mapping is odd, and nothing will be returned. If there is an even number of parameters, the last value is considered default and returned if no keys equal an object. To simplify understanding, the keys are underlined below.

Examples:

  • {{map(‘ Y,' ‘R,' 'Red,' ‘O’, ‘Orange,' ‘Y,' ‘Yellow,' ‘B,' ‘Blue,' ‘G,' ‘Green,' ‘P,' ‘Purple,' ‘Black’)}} will return Yellow. In a document, you will write it simply as {{map(‘Y,' ‘R', 'Red', ‘O’, ‘Orange', 'Y’, 'Yellow’, 'B’, 'Blue', ‘G,' ‘Green', 'P', ‘Purple', 'Black’)}}

  • {{map(‘ M’, ‘R', 'Red', ‘O’, ‘Orange’, ‘Y’, ‘Yellow’, ‘B’, ‘Blue’, ‘G', ‘Green', ‘P,' ‘Purple', ‘Black’)}} will return ‘Black’, because no key for ‘M’ was found, and as soon as ‘Black’ doesn’t have a corresponding value, it will be accepted as a default value. 14 arguments (including numbers) were passed for mapping.

  • {{map(‘ M’, ‘R’, ‘Red’, ‘O’, ‘Orange’, ‘Y’, ‘Yellow’, ‘B’, ‘Blue’, ‘G’, ‘Green’, ‘P’, ‘Purple’)}} will not return anything, because there are no unmatched keys. The number of arguments is 13 (an odd number).

  • charAt(string_value, index) – return a letter, that is in string_value on the spot index. The count starts with 0. If the index is negative, fractional, larger, or equal, then string_value number of letters, an empty string will be returned. The result will be treated as a string value.

Examples:

  • {{charAt(‘Abcdefg’, 2)}} will return ‘c’

  • {{charAt(‘Abcdefg’, 0)}} will return ‘A’

  • {{charAt(‘Abcdefg’, 37)}} will not return anything.

  • contains(string_value, pattern) – returns true if string_value contains pattern. The function is case-sensitive.

Examples:

  • {{contains(‘Taste this piece of pie’, ‘is piec’)}} will return true

  • {{contains(‘Taste this piece of pie’, ‘taste’)}} will return false

  • endsWith(string_value, string_pattern) – a function that returns a true or false value. Function will return true if string_value ending matches string_pattern. The function is case-sensitive.

Examples:

  • {{endsWith(‘Dedalus Diggle’, ‘Diggle’)}} will return true.

  • {{endsWith(‘Dedalus Diggle’, ‘diggle’)}} will return false because ‘D’ is not equal to ‘d’

  • equalsIgnoreCase(string_value_1, string_value_2) – a function that returns true or false, depending on the equality of string_value_1 and string_value_2. Is case insensitive, meaning that it returns true if a lower case of string_value_1 is equal to the lower case of string_value_2

Examples:

  • {{equalsIgnoreCase(‘Bart Simpson’, ‘bart SIMPSON’)}} will return true because to lower case both strings will equal ‘bart simpson’.

  • {{equalsIgnoreCase(‘Rolling Stones’, ‘Roll that Stone’)}} will return false.

  • length(string_value) – returns the number of symbols in a string value.

Examples:

  • {{length(‘Abcde’)}} will return 5

  • {{length(‘’)}} will return 0

  • {{length(‘Annoying orange’)}} will return 15

  • replace(sting_variable, pattern1, pattern2) – finds all occurrences of pattern1 in sting_variable and replaces it with pattern2. If pattern1 is not found in the string, will return sting_variable.

Examples:

  • {{replace(‘JHMAB52EC8oo65o’,‘o’,‘0’)}} will return ‘JHMAB52EC800650’

  • {{replace(‘That’s what you get for waking up in Vegas’, ‘Vegas’, ‘New York’)}} will return ‘That’s what you get for waking up in New York’.

  • split(string_value, pattern, index). To perform this function, all pattern occurrences are found in string_value. A string is broken into a list of strings as if any pattern occurrence means the previous string ends and the next string starts after it. A piece with an index number in this list starting from zero will be returned. Nothing will be returned if an index exceeds the number of pieces in the list.

Examples:

  • {{split(‘To be or not to be?’, ‘ ’ , 5 )}} will be split by space into ‘To’, ‘be’, ‘or’, ‘not’, ‘to’ be?’; starting from 0 the piece of string, that has index 5 will be ‘be?’, so ‘be?’ will be returned.

  • {{split(‘John|Mathews|47|Approved’ , ’|’ , 1)}} will return ‘Mathews’

  • startsWith(string_value, string_pattern) – a function that returns a true or false value. The function will return true if string_value beginning matches string_pattern. The function is case-sensitive.

Examples:

  • {{startsWith(‘Meet me in London’, ‘Meet’)}} will return true.

  • {{startsWith(‘Meet me in London’, ‘meet’)}} will return false because ‘M’ is not equal to ‘m’.

  • substring(string_value, start), substring(string_value, start, end) – returns a piece of string. If two arguments are passed, then the ending of a string starts from the start index. In case of three arguments, a piece of string_value starting from the start symbol to the end symbol will be returned. Letter with index end will not be included. The first letter has an index of 0.

Examples:

  • {{substring(‘0123456’ , 2 , 5)}} will return ‘234’.

  • {{substring(‘0123456’ , 3)}} will return ‘3456’.

  • titleCase(string_value) – will return string_value with all first letters to uppercase.

Examples:

  • {{titleCase(‘When in Rome, do as the Romans’)}} will return “When In Rome, Do As The Romans”.

  • {{titleCase(‘When the going gets tough, the tough get going’)}} will return “When The Going Gets Tough, The Tough Get Going”.

  • toLowerCase(string_value) – will return string_value with all first letters to uppercase.

Examples:

  • {{toLowerCase(‘When iN Rome, dO as tHe RomAns’)}} will return “when in rome, do as the romans”.

  • {{toLowerCase(‘WhEn thE goiNg getS toUGh, the tOUgh get goINg’)}} will return “when the going gets tough, the tough get going”.

  • toUpperCase(string_value) – will return string_value with all first letters to uppercase.

Examples:

  • {{toUpperCase(‘When iN Rome, dO as tHe RomAns’)}} will return “WHEN IN ROME,DO AS THE ROMANS”.

  • {{toUpperCase(‘WhEn thE goiNg getS toUGh, the tOUgh get goINg’)}} will return “WHEN THE GOING GETS TOUGH, THE TOUGH GET GOING”

  • toUpperCaseFirst(string_value) – will return string_value with the first letter capitalized.

Examples:

{{toUpperCaseFirst(as of March 05, 2024)}} will return “As of March 05, 2024".

  • trim(string_value) removes spaces at the beginning and the end of a string

Examples:

{{trim(‘ 12CVCV123-454 ’)}} will return “12CVCV123-454”.

Fillable fields

In most cases, it is recommended that you use the Fields panel to drag and drop fillable fields into your document. However, if needed, you can add fillable fields using the fillable field tag syntax.

Field

Example

Text

{{t:t;r:n;l:"text_field _1";}}

Signature

{{t:s;r:n;l:"signature_field _1";}}

Initials

{{t:i;r:n;l:"initials_field _1";w:200;}}

Dropdown

{{t:d;r:n;l:"Dd_field _1";dd:first option,second option,third option;w:200;}}

Checkbox

{{t:c;r:n;l:"checkbox_field _1";}}

Date

{{t:dt;r:n;l:"date_field _1";w:150;p:"DD/MM/YYYY";}}

The table below shows the most widely used fillable field tags in Document Generation and the types of fields to which they can be applied.

KEY

What does it mean?

Accepted format & values

Example

t

TYPE of the field

s (for signature)

i (for initials)

t (for text)

d (for dropdown)

c (for checkboxes)

dt or date (for dates)

-

r

REQUIRED

y (for required)

n (for optional)

-

l

LABEL

“Field name”

-

dd

DROPDOWN

"option1, option2,

option3, ...."

-

w

WIDTH

w (width)

-

h

HEIGHT

h (height)

-

p

DATE FORMAT

MM/DD/YYYY

09/13/2024

DD/MM/YYYY

13/09/2024

HH:mm

02:30

MMM DD, YYYY

Sep 13, 2024

MM/DD/YY

09/13/24

YYYY-MM-DD

2024-09-13

YYYY/MM/DD

2024/09/13

YYYY-M-D

2024-9-13

YYYY/M/D

2024/9/13

D.M.YYYY

13.9.2024

D-M-YYYY

13-9-2024

D/M/YYYY

13/9/2024

DD.MM.YYYY

13.09.2024

DD-MM-YYYY

13-09-2024

Outcome: Once a PDF document has been generated from a DOCX, fillable field tags in your DOCX document will be automatically converted into fillable fields. Such fillable fields can then be mapped as usual while configuring your bots.

Did this answer your question?