HomeGuidesChangelogDiscussions
GuidesDiscussionsChangelogLog In

DocX / PptX template syntax

Use the DaDaDocs DocX syntax to markup your documents to work correctly with Salesforce.

Tag syntax. About tags

{{tag}} – this is the basic structure of a tag.

{{ – stands for tag opening and }} for tag closing.

Tags may contain one or two parts. Tags if, table, tableIf, require the second closing tag.

In tags that require reserved syntax, don’t put space symbols between the reserved word and tag opening.

{{if()}} is valid, {{ if() }} is invalid.

For displaying strings use ‘this’ quotation marks only!!!

Tag openingTag closingDescription
{{expr}}, {{data}}Tags that perform calculation, display data, etc.
{{link=data}}Insert a hyperlink into document.
{{$var=data}}

{{$var=127.2}}

{{$var=‘String’}}

{{$var=true}}

{{$var=null}}
Lookup the data associated with “data” and assign it to the variable “var”. Assign the number 127.2 to variable $var. Assign the string “String” to variable $var. Assign the boolean true to variable $var. Assign the value null to variable $var.
{{$var}Lookup the variable “var” and render its value
{{html:htmlData}}htmlData will be fetched and inserted as html content into the document at this location
{{if(name)}}

{{f({expr})}}

{{if($var)}}
{{endif}}Content between the opening element and the closing element is included or excluded depending on the value associated with “name” or the expression “expr” or the variable “var”. The end tag must be аnonymous: {{endif}}.
{{for(data)}}

{{for($var)}}

{{for(data).skip(N))}}
{{endfor}}Content between the opening element and closing {{endfor}} element is repeated whilst there is data associated with “data” or the variable “var”. When stepping is used, the built-in variable $currIndex is related automatically so you can reference the items available in each step.
{{tableIf(data)}}

{{tableIf({expr})}}

{{tableIf($var)}}
{{endtable}}Include the following table rows depending on the value associated with “data” or expression “expr” or the variable “var”.
{{table(data)}}

{{table($var)}}

{{table(data).step(N)}}
{{endtable}}The rows between the opening element row and the closing element row are repeated whilst there is data associated with “name” or the variable “var”. “.step(N)” indicates that the “data” should be iterated in steps of N size. When stepping is used, the $currIndex variable is created automatically
{{columnIf(data)}}Include or exclude the table column containing this field depending on the value associated with “data” or the expression “expr” or the variable “var”.
{{remslide(condition)}}Remove a slide from .pptx presentation if condition is positive.

Declaring and assigning variables

{{$variableName = VariableValue}} creates a variable, named variableName in template environment and assigns it value VariableValue. If a variable named variableName already exists, its value is rewritten and is assigned VariableValue name. You will not be able to reach $variableName previous value, if it is overwritten.

{{$var = 5.48}}Assign variable $var value 5
{{$var = ‘Harry Potter’}}Assign variable $var a string value ‘Harry Potter’
{{$var = Opportunity.Name}}Assign variable $var a value from data source
{{$var = 5 + 47 / 2 – 34 * Company.Price}}Assign variable $var a calculated value
{{$var = true}}Assign variable $var and assign it boolean value true
{{$var}}Display value of $var
{{$var > 47}} {{endsWith(Opportunity.Name, $var)}}Example of using variable in calculations and functions

Reaching objects and fields from data source.

Let’s imagine a simple structure from Salesforce. Let it be an account with 4 opportunities. Each opportunity has 0 – 4 attachments. All objects will have name fields only. If described in JSON, this object will look as follows:

851

Various ways to select objects (note, that all indexes start from 0, so Op1 will have index 0):

InputOutputExplanation
Account.Opportunites.
Attachments.Name or Account.Opportunities[*]. Attachments[*].Name
At11, At12, At13, At21, At22, At31, At32, At33, At34Select all opportunities. In those opportunities select all attachments. In those attachments select all names.
To select all objects [*] works fine too.
AtAccounttachment.
Opportunities[first()].
Attachments[last()].Name
At13Select first opportunity.
In that opportunity select last attachment and display its name.
Account.Opportunities[first(2)].
Attachments[last(2)].Name
At12, At13, At21, At22Select first two opportunities.
In each of them, select the last two attachments and display their names.
Account.Opportunities[2].
Attachments[1-4].Name
At32, At33, At34Get third object from opportunities (indexing starts from 0, so Opportunities[2] really means the third opportunity in the list).
From that opportunity you get second, third, fourth and fifth attachments. As soon as fifth attachment is missing, only 2, 3, 4 will be displayed.
Account.Opportunities[2,0].
Attachments[3, first(2)].Name
At34, At31, At32, At11, At12Get third and first opportunity. From them, get the name of the fourth, first and second attachment.
As soon as the first opportunity has three attachments only, the fourth attachment will not be displayed.
Account.Opportunities.
Attachments[3-1].Name
At13, At12, At22, At34, At33, At32List all opportunities. List attachments from fourth to second in reverse order.
If attachments are missing they will not be displayed.
Account.Opportunities[first(), 0].
Attachments[last(), 2].Name
At13As soon as opportunity indexed with 0 and the first opportunity are the same and for opportunity with 3 attachments last attachment and attachment with index 2 is also the same, only one attachment will be displayed.
Account.Opportunities.
Attachments[0-last(2)].Name
At11, At31, At32Display attachments for all opportunities starting from 0 excluding the last two cases.
Account.Opportunities.
Attachments[1-$size].Name
At12, At13, At22, At32, At33, At34Display for all opportunity objects starting from second (index1) to the last one.
Account.Opportunities.
Attachments.$size
93 + 2 + 4 + 0 attachments for each opportunity.
Account.Opportunities[3,2,1].
Attachments.$size
60 + 4 + 2. All modifiers applied in size property remain the same.

To access objects for tag and table tag, just add the fieldname and you will receive a list of objects passed to the template.

To access fields outside {{for}} and {{table}}, use the example above with the fieldname (not between {{for}} and {{endfor}}. See chapter about iteration).

To access fields in {{for}} tag (for table tag it’s just the same), you can also use $parent and $root modifiers. $parent stands for objects to the left (Account is parent of Opportunity, Opportunity is parent of Attachment). $root is the first object to the left. In our case it will always and everywhere be Account. To access fields by names in iterable object, just use the name of a field itself not using the path to reach it.

{{for(Account.Opportunities)}}

  • {{Name}} will equal Op1, Op2, Op3, Op4 for each opportunity. Opportunities are iterable objects.
  • {{$parent.Name}} and {{$root.Name}} will be the same: Account1, because Account is both a parent object and a root object for opportunity.
  • You can use {{Attachments.Name}} to list names of attachments, corresponding to the iterable opportunity. If you want to perform more complicated actions, use another one {{for}} cycle, like the one above.

{{for(Attachments)}}

  • {{Name}} for Op1 will equal At11, At12, At13 corresponding to cycle. While Account.Opportunities cycle iterates, the name list will change.

  • {{$parent.Name}} will be Op1 for the first outer cycle.

  • {{$root.Name}} will always be Account1.

    {{endfor}} (Don't forget to close each for cycle!)

{{endfor}}

Arithmetic and logical operations (+-*/%&||!= ==)

Binary operations:

Binary operations contain two parameters. Any function that returns a required type of data or string can be passed as a parameter. Addition can accept both Strings and numbers as parameters; if string parameters are passed, then they will be concatenated. Expressions in braces have the highest priority.

Operations with priority declining:

*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 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

46

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 type of expression, returns false if expressions are equal

{{45 != 5 * 9}}

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

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

true

true
=,==Accepts any type of 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, that consumes a boolean and reverts it. Use the ! sign to perform this operation. For example: !(2 > 5) will return true.

String and numeric functions

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 object, next values are split into key-value pairs. The obj is compared to keys, and if a key matches an object, that value will be returned. If any key does not match an object, then the number of parameters passed to map is odd, and nothing will be returned. If there is an even number of parameters, then the last value is considered default and is returned if no keys equal an object. To simplify understanding, keys are underlined below.

Examples:

  • {{map(‘Y’, ‘R’, ‘Red’, ‘O’, ‘Orange’, ‘Y’, ‘Yellow’, ‘B’, ‘Blue’, ‘G’, ‘Green’, ‘P’, ‘Purple’, ‘Black’)}} will return Yellow. In template 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 – even number – were passed to map.

  • {{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 – odd number.

  • charAt(string_value, index) – return a letter, that is in string_value on the spot index. Count starts with 0. If index is negative, fractional or 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. 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 true or false value. Function will return true, if string_value ending matches string_pattern. 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) – function, that returns true or false, depending on equality of string_value_1 and string_value_2. Is case insensitive, meaning that returns true if lower case of string_value_1 is equal to 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 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 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 occurrences of pattern are found in string_value. string is broken into a list of strings, as if any occurence of pattern means that previous string ends and after it next string starts. A piece, that is has index number in this list starting from zero will be returned. If index is bigger than number of pieces in list, then nothing will be returned.

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 true or false value. Function will return true, if string_value beginning matches string_pattern. 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 string starting from start index. In case of three arguments, a piece of string_value starting from start symbol to end symbol will be returned. Letter with index end will not be included. First letter has index 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:

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

  • {{toTitleCase(‘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”

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

Examples:

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

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 closest whole number, that is bigger, then passed 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 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 a 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).

  • sin(num_value) – return a sine of a number in radians.

Examples:

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

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

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

  • cos(num_value) – return a 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).

Formatting functions

  • dateFormat(date, current_date_format, required_date_format)

dateFormat(date, current_date_format, required_date_format, date_modifier)

Encoding and decoding format of date

647

Example for formatting date:

{{dateFormat( ‘2018-10-16 06:45:22’, ‘yyyy-MM-dd HH:mm:ss’, ‘yyyy-dd-MM’)}}“2018-16-10”
{{dateFormat( ‘2018-10-16 06:45:22’, ‘yyyy-MM-dd HH:mm:ss’, ‘EEE, d MMM yyyy HH:mm:ss Z’)}}Tue, 16 Oct 2018 06:45:22 +0300

Date modifier functionality:

date_modifier – a string, that contains 6 whole numbers: for year, month, day, hour, minute, second. Positive number adds a unit, negative subtracts, zero keeps the same. Numbers are separated with space.

‘1 0 0 0 0 0’Add 1 year
‘-1 0 0 0 0 0’Subtract 1 year
‘0 2 0 0 0 0’Add two months
‘0 -2 0 0 0 0’Subtract two months
‘0 0 10 0 0 0’Add ten days
‘0 0 -10 0 0 0’Subtract 10 days
‘0 0 0 5 0 0’Add 5 hours
‘0 0 0 -5 0 0’Subtract 5 hours
‘0 0 0 0 174 0’Add 174 minutes
‘0 0 0 0 -174 0’Subtract 174 minutes
‘0 0 0 0 0 21’Add 21 second
‘0 0 0 0 0 -21’Subtract 21 second
‘1 -2 -3 4 0 8’Add 1 year, 4 hours, 8 seconds. Subtract 2 months and 3 days.

{{dateFormat(‘2018-10-16 06:45:22’, ‘yyyy-MM-dd HH:mm:ss’, ‘d MMM yyyy HH:mm:ss’, ‘1 -2 4 -3 -5 16’ )}} will return “20 Aug 2019 03:40:38”

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

About Number formatting

787

numFormat(number, string_format, groupseparator_symbol, decimalseparator_symbol) is also accepted.

Use it if you want to see other separators but comma and dot in a formatted number. Group separators replace commas and decimal separators take the place of dots.

Examples:

numFormat(16326.2298, ‘###,###.00’)16,326.23‘###,###.00’ rounds a number to exactly two signs after coma.
numFormat(16326.2, ‘###,###.00’)16,326.20“‘###,###.00’ adds zeros if expression has less signs after coma then it is required.”
numFormat(16326, ‘###,###.00’)16,326.00‘###,###.00’ adds decimal part even if number is whole
numFormat(16326.2298, ‘###,###.##’)16,326.23‘###,###.##’ rounds expression to two signs after coma if number has more
numFormat(16326.2, ‘###,###.##’)16,326.2‘###,###.##’ keeps number shorter if there are allowed less decimals then the number really has
numFormat(16326, ‘###,###.##’)16,326‘###,###.##’ will not add zeros to whole number
numFormat(16326.2298, ‘###,###’)16,326removes decimal part
numFormat(16326.2298, ‘000,000.##’)016,326.23‘000,000.##’ adds zeros before number to match six numbers before comma
numFormat(1633444426.2, ‘000,000.##’)1,633,444,426.2example of group separator for large number
numFormat(26, ‘###,000.##’)026‘###,000.##’ keeps three signs before coma
numFormat(1633444426.2, ‘###,000.##’, ‘!’, ‘#’)1!633!444!426#2Replace group separator with ! and decimals with #
numFormat(1633444426.2, ‘###,000.##’, ‘ ’, ‘.’)1 633 444 426.2Replace group separator with space and decimal separator with dot.
numFormat(12345.67, ‘\u00A5###,###.###’)¥12,345.67The pattern specifies the currency sign for Japanese yen (¥) with the Unicode value 00A5.
numFormat(12345.67, ‘$###,###.###’)$12,345.67The first character in the pattern is the dollar sign ($). Note that it immediately precedes the leftmost digit in the formatted output.
numFormat(12345.67, ‘-###,###.###’)-12,345.67The first character in the pattern is the minus sign (-).Note that it immediately precedes the leftmost digit in the formatted output.
numFormat(0.1234, ‘###,###.###%’)12.34%multiply by 100 and show as percentage
numFormat(0.1234, ‘###,###.###‰’)123.4‰multiply by 1000 and show as per-mile
numFormat(4444445554545.655547, ‘0.0E0’)4.4E12Adds scientific formatting to decimal
numFormat((1000*5)%10/50 + 5, ‘###,###’)5Supports embedded math operations
numFormat(1000*5/(50%10), ‘###,###’)Dividing to zero gives infinity

Aggregate functions: min, max, sum and avg.

min(args), max(args), avg(args), sum(args) finds a list of corresponding minimum, maximum and average for parameters passed.

min and max can accept numbers, strings and dates. avg consumes dates only.

If numbers are passed to min and max they are compared in natural ordering. If strings are passed, they are compared alphabetically. To apply comparing dates create $dateFormat variable {{$dateFormat = ‘Your dates date format here’}} before using aggregates. If dates could not be parsed according to your formatting, they will be treated as strings.

Agrs passed can be of several different types:

  • a list of values. For example: {{min(5, 14, -948.256)}} will return -948.256. A variable can also be a memeber of a list.
  • a list of objects (see part Reaching objects and fields from data source). Using object described in Reaching objects and fields from data source {{max(Account.Opportunities.Attachments.Size)}} will be 40.
  • a combination of them.

{{avg(0, -min(Account.Opportunities.Attachments.Size),

Account.Opportunities.Attachments.Size)}}

will be treated as an average of list:

0, –11, 11, 12, 13, 21, 22, 31, 32, 33, 34, 40 where 0 is an argument passed, Account.Opportunities.Attachments.Size is a list of values from the right column of an object described, 11 is the smallest of those sizes with mathematical operation “–” applied. The result will be 19.88.

Corresponding {{sum(0, –min(Account.Opportunities.Attachments.Size), Account.Opportunities.Attachments.Size)}} will equal 238.

Conditional tags. {{if}}

Conditional tags allow for performing different actions depending on some condition. Basic syntax:

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

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

{{if(condition1)}} success action if condition 1 is true {{else(condition2)}} action if condition 2 is true {{else}} action performed if all previous conditions are false {{endif}}**

condition can be any expression, variable or value from a datasource, a function or calculation. Depending on the value that is passed or calculated, conditions are evaluated using the following:

Type of variable, value or result of a calculation or functionRange for true valueExample of trueRange for false valueExample of false
BooleanBoolean trueTrue
2 < 5 equalsIgnoreCase( ‘Cat’, ‘cat’)
Boolean falseFalse
4 > 8

2 == ‘Teapot’
StringNon-empty string‘Anny’, ‘Jane’, ‘New York’, ‘To be or not to be?’Empty string‘’
NumberAll non-zero values1, 0.004, -10293, 24, 32.445, -473.927Zero0
NullAlways falseNull,

Tag {{if}} may include some extra conditions. They are included after {{else}} tag in round brackets (ex. {{else(2 < 3)}}. If condition in {{if}} part is false, algorithm goes one by one, all others part with conditions and look for the first one, whose condition is equal to true. If {{else}} has no condition, it will be treated as {{else(true)}} and executed when reached.

Parts between tags may include other tags. If another {{if}} tag is present, don’t forget, that {{endif}} for both of them is required.

To simplify understanding tags will be colored with blue, positive condition with green, negative condition with red.

Examples:

ExampleOutputExplanation
{{if(contains(‘God save the Queen!’, ‘Queen’))}}

“God save the Queen” contains word “Queen”

{{else}}“God save the Queen” does not contain word “Queen” {{endif}}
“God save the Queen” contains word “Queen”Condition in {{if}} part is true, so part between {{if}} and {{else}} is returned.
{{$num = 10}}
{{if($num > 17 –

5)}}{{$var=11}}{{else($num>12 + 1)}}{{$var=true}}{{else($num < 8 / 3)}}{{$var=7+4}}{{else}}{{$num= ‘Result’}}{{endif}}{{$num}}
ResultVariable $num with value 10 is created.

1. Evaluating condition in {{if}}

$num > 17 – 5; 10 > 17 – 5; 10 > 12; false.

2. Go to first else. As soon as it has condition, it will be evaluated.

$num>12 + 1; 10 > 12 + 1; 10 > 13; false

3. Go to second else. It has condition.

$num < 8 / 3; 10 < 8/ 3; 10 < 2.66; false;

4. Go to last else. It has no condition, so it will be executed. Variable $num is created and assigned a string value ‘Result’.

5. Part that was executed in tag contained no text to display, so whole tag will be deleted after creating variable.

6. Display value of $num variable. ‘Result’ will be displayed.
{{if(false)}}I will not be displayed {{endif}}Condition is false, so no tag content will be displayed.
{{if(true}} Missing right brace in if tag. Exception will occur and whole tag will be removed. {{endif}}Missing right brace in if tag. Exception will occur and whole tag will be removed.

Image tag

Document processor supports inserting images into a document. To see if your image can be inserted, copy the url link and paste it as a web address in the browser. If your image is opened as an image, everything is fine and your image will be successfully inserted. Otherwise, tag will be removed.

When using the image tag in pptx, be sure not to add any other data in this text field. Doing so will cause the text field to be replaced with an image field all data will be lost.
When tagging .pptx files, all tags in .pptx files can be used normally.

ElementDecription
{{image(url)}}inserts image. If it is larger than page width, resizes it to fit page.
{{image(url).width(points)}}inserts an image and rescales it to fit certain width.
{{image(url).height(points)}}inserts an image and rescales it to fit certain height.
{{image(url).height(points).width(points)}}resizes an image to width and height.

Link tag

{{link=‘link_url’}} inserts a url into document. Not supported in text boxes.

{{link=‘www.google.com’}} will result into www.google.com.

Html tag

Template processor support displaying text from html code (Rich Text fields in Salesforce).

It displays tags similar to way, they are displayed in organization.

Currently supported tags:

  • <image> for inserting images

  • <a> for links. If <a> has no content, then link from href attribute will be displayed

  • <ul>,<ol>, <li> – ordered and unordered lists. Currently only single-level lists are supported.

  • <p><div><span> – stand for holding text as containers.

  • </br> paragraph break;

  • Text formatting: <u>, <i>, <strike>, <b> tags for underlining, italic, striked text, bold; <sub> and <sup> for subscript and superscript; paragraph attributes color, size. font.

Tables inside html are not supported in current version.

Iterating data. Tags {{for}} and {{table}}

If your object has child objects, you might want to iterate child objects and use their fields one by one. There are two ways to do it: for tag and table tag.

Use for tag if you want to use data in plain text or in a table cell. Table tag creates a new block of table rows for each object.

In .pptx files, tag for must be placed inside one text area and will be displayed as very long text. Repeating data in different slides is not currently supported, but we are working on it.

A Table tag can be used just the same way as in .docx tables, but they might not fit into the slide height if your data set is too large.

For tag:

Syntax:

{{for(object_list)[.skip(N).step(M)]}}

action

{{endfor}}

Example for object described in Reaching Objects and fields from data part.

{{for(Account.Opportunities)}}
This table will be repeated for each Opportunity.

{{$currIndex}}{{Name}}

Data below will become an unordered list.

{{for(Attachments)}}

  • {{Name}}, {{Size}}

{{endfor}}

{{endfor}}

Result of execution:

This table will be repeated for each Opportunity.

1Opportunity1

Data below will become an unordered list.

· 11.txt,

· 12.txt,

· 13.txt,

This table will be repeated for each Opportunity.

2Opportunity2

Data below will become an unordered list.

· 21.txt,

· 22.txt,

This table will be repeated for each Opportunity.

3Opportunity3

Data below will become an unordered list.

· 31.txt,

· 32.txt,

· 33.txt,

· 34.txt,

This table will be repeated for each Opportunity.

4Opportunity4

Data below will become an unordered list

**Table tag:

Syntax:**

{{table(Object_list))[.skip(N).step(M)]}}
actionaction
{{endtable}}

For example in Reaching Objects and fields from data part.

#Account NameOpportunity NameAttachment NameAttachment Size
{{table(Account.Opportunities.
Attachments)}}
{{$currIndex}}{{$root.Name}} or {{$parent.$parent.Name}}{{$parent.Name}}{{Name}}{{Size}}
{{endtable}}

Result:

#Account NameOpportunity NameAttachment NameAttachment Size
1Account1 or Account1Opportunity111.txt11
2Account1 or Account1Opportunity112.txt12
3Account1 or Account1Opportunity113.txt13
4Account1 or Account1Opportunity221.txt21
5Account1 or Account1Opportunity222.txt22
6Account1 or Account1Opportunity331.txt31
7Account1 or Account1Opportunity332.txt32
8Account1 or Account1Opportunity333.txt33
9Account1 or Account1Opportunity334.txt34

And if you want to display data as a tree:

Account NameOpportunity NameAttachment NameAttachment Size
{{Account.Name}}{{table(Account.Opportunities)}}
{{Name}}{{table(Attachments)}}
{{Name}}{{BodyLength}}
{{endtable}}
{{endtable}}

**Notice, that you must close both {{table}} tag with {{endtable}}

Result:**

Account NameOpportunity NameAttachment NameAttachment Size
Account1Opportunity111.txt11
12.txt12
13.txt13
Opportunity221.txt21
22.txt22
Opportunity331.txt31
32.txt32
33.txt33
34.txt34

Step and skip

Step and skip are not mandatory options, that allow you more freedom in formatting templates.

Skip(N) – skips N objects before starting iteration.

Step(N) – uses in one iteration a few objects. You can reach them as $iN.

Example:

**{{for(Account.Opportunities.Attachments).step(3)}}

{{$i1.Name}} {{$i2.Name}} {{$i3.Name}}

{{endfor}}**

11.txt 12.txt 13.txt
21.txt 22.txt 31.txt
32.txt 33.txt 34.txt

Use {{$size}} to see the size of iterating objects, {{$currentIndex}} to get the number of the current iteration.

Extra tags for tables: columnIf, tableIf, $rowCount, $sumAbove

  • tableIf – allows for the removal of unwanted lines from a table. Can be used both inside and outside {{table}} tag. Requires {{endtable}} closing tag. In .pptx files table area will be completely removed if no lines remain and this part of slide will just look empty.

Examples:

In .pptx files, the table area will be completely removed if no lines remain. This part of the slide will appear empty.

{{tableIf(Account.Opportunities.$size > 2)}}
{{Account.Name}}{{Account.Opportunity[0].Name}}
{{Account.Opportunity[1].Name}}
{{Account.Opportunity[2].Name}}
{{endtable}}
  1. Only display objects in table that match certain conditions. For example, display only Attachments – whose name does not end with 2.
#
{{table(Account.Opportunities.
Attachments)}}
{{tableIf(!endsWith(0Name, ‘2’))}}
{{$currIndex}}{{$root.Name}} or {{$parent.$parent.Name}{{$parent.Name}}{{Name}}{{Size}}
{{endtable}}
{{endtable}}
  • columnIf allows for the removal of columns if they don’t match some condition. Must be outside of table tag.

Example:

You don’t want to show column size if sum of all sizes (or prices) is less than 10 000.

#Account NameOpportunity NameAttachment NameAttachment Size
{{table(Account.Opportunities.Attachments)}}
{{$currIndex}}{{$root.Name}} or {{$parent.$parent.Name}}{{$parent.Name}}{{Name}}{{Size}}
{{endtable}}
{{columnIf(sum(Account.
Opportunities.Attachments. Size) < 10000)}}
  • fixedstyle – prevents switching colors in tables
#Account NameOpportunity NameAttachment Name
{{table(Account.Opportunities.
Attachments)}}
{{fixedstyle}}
{{$currIndex}}{{$root.Name}} or
{{$parent.$parent.Name}}
{{$parent.Name}}{{Name}}
{{endtable}}
  • {{$rowCount}} displays total number of rows in table. Use it just as a variable.

  • {{$sumabove}} displays sum of numbers in cells above this tag. Supports 2 number formats: ######.# and $######.#. Can be used as a parameter in calculations like {{$sumabove + 10}} or as a parameter in functions like {{numFormat($sumabove, ‘$###,###.00’}}.

Page break and column break (unavailable for .pptx files)

  • {{pageBreak}} adds a page break.
  • {{columnBreak}} breaks a column (column refers to page formatting like one in newspapers, not to tables)
  • {{pageBreakNotLast}} ,{{columnBreakNotLast}} are used inside {{for}} tag. They insert page breaks and column breaks unless the item is the last in the cycle.

Removing an unwanted slide on condition

In pptx, you have the option to remove the slide on condition - for example, you have no data for a table and don’t want to see an empty table with no informative data.

Just add {{remslide(condition)}} in any area of the pptx text. If the condition is “true”, the slide will be removed from the presentation.

In the example of a table, it will appear as {{remslide(Opportunity.OpportunityLineitems.$size = 0)}}
If the condition is “false”, the tag will be removed from the presentation and other data on the slide will not be affected.

Checkboxes for .dox documents

You can create a checked or unchecked clickable checkbox in your template just by using {{checkbox(condition)}} tag. If condition is “true” your checkbox will be checked. Otherwise, it will be unchecked. Read more about conditions in the {{if}} tag section.

Limitations:

  • Requires strict quotation marks in string variables. Use ‘ for opening a string and ’ for closing. Other types of quotation marks will be ignored.
  • Text box elements are processed after the entire document has been processed. Variables created in textboxes will be visible only to other textboxes.
  • Text boxes support only simple tags (performing calculations, functions, displaying data, creating and assigning variables. If, for, link, html are not supported in textboxes.
  • Only tables in documents are supported. Tags in embedded tables or tables in textboxes will not be processed or may be processed invalidly.
  • In case of invalid syntax, tag will be replaced with an empty string.