Document Generator Microsoft Word Document Syntax

 

Template expressionsAny kind of string Template Expression[[Title]] [[Firstname]] 
Assignment ExpressionsStart with "[[=" and any kind of string Expression[[= [[Title]] + ", " + [[Firstname]] ]]
Function Code ExpressionsStart with "[[{" in the Tag property. Write your complex expression as content in the placeholder[[{ var arr = [[@Web.GetValuesForQuery('OtherList', '<View></View>', 'Total')]]; var sum = 0; arr.forEach(n=>sum +=n); return sum; }]]
Lookup Values

Use the [[Lookup.FieldInternalName]] notation to get any value from the target list of a lookup

*doesn't work in Scheduled & Triggered actions

Examples:
[[Department.Code]]*
[[Department.Author]]*
[[Department.Key]] -> to get the item ID of the department
If ConditionsStart with [[if …]] and any kind of boolean Expression (Condition).
Ends with [[end if]] 
Everything between the starting and the ending tag will be visible if the condition is true. This can be text, an image etc.
[[if [[Budget]] > [[Outgoings]] ]]
[[Title]]
[[end if]]

[[if {return ([[Budget]] > [[Outgoings]]);} ]]
[[Title]]
[[end if]]

[[if [[Status]]!="Completed" ]]
[[Title]]
[[end if]]
Loops

Start with [[loop]] for looping over multiple items of the selected list.
If a CAML Query is configured for this action link, looping will be filtered according to it.
Start looping over the sublist items filtered by lookup to the parent list using one of the following methods:

1.SublistTitle. For example, [[loop SublistTitle]]
2.List ID. In this case you need to follow these steps:
- Create Variable in Action Builder with List ID as its values. During Package & Publish, this List ID will be automatically replaced with the ID of the list on the deployment site.
- In the document template use Variable placeholder.
For example, [[loop [[@Variables.SubItemListID]] ]]
Note: [[@Variables.SubItemListID]] placeholder should have space before double brackets.

Use filterlookupfield('field_internal_name') param to specify which lookup field to use for sublist in a case when several lookups on the same list exist. It’s optional where there is just one lookup field. Also RowLimit is hardcoded for 200 items for query, but the required number can be specified with the optional rowlimit(number) param.
If list that is not a sublist is selected (doesn’t have lookup to the list selected in action link configuration), no filtering will be applied.
Iteration ends with [[end loop]]

[[loop]]
[[Title]]
[[end loop]]

[[loop SubListTitle filterlookupfield('field_internal_name') rowlimit(number)]]
[[Title]]
[[Firstname]]
[[end loop]]
Filtered LoopsWhere SomeView is a view .aspx page title, such as AllItems.
The order and filter of the view are applied. If CAML query is added (optional), it is united with the view query using an ‘and’ operator.
[[loop SublistTitle view('SomeView') query('<Where><BeginsWith><FieldRef Name="Title" /><Value Type="Text">[[{return [[Title]];}]]</Value></BeginsWith></Where>')]]
[[Title]]
[[end loop]]
Loops over documents in sublibrariesUse the Scope="Recursive" property on the query to get documents in a folder, when used as sublibrary of a form. Combine recursive scope and filter in CAML query to filter the listed document’s metadata.[[loop SublibraryName query('<View Scope="Recursive"></View>')]]
[[FileLeafRef]]
[[Title]]
[[OtherField]]
[[end loop]]

[[loop SublibraryName query('<View Scope="Recursive"><Query><Where><Eq><FieldRef Name="IsActive" /><Value Type="Boolean">1</Value></Eq></Where><OrderBy></OrderBy></Query></View>')]]
[[FileLeafRef]]
[[Title]]
[[OtherField]]
[[end loop]]
Nested Loops

Looping over a sublist inside of the loop over multiple items of the parent list is supported.
Looping over several sublists, or a sublist of a sublist are supported as well.

In case [[@Loop.Parent.FirstName]] placeholder is used it allows retrieving parent loop data inside nested loop. Possible formats:
[[@Loop.Parent.Field1]]
[[@Loop.Parent.LookupField1.Field2]]
[[@Loop.Parent.Parent.Field3]]
[[@Loop.CurentIndex]]
[[@Loop.Count]]
 

[[loop]]
     [[Title]]
          [[loop SubList1]]
               [[Title]]
               [[Firstname]]
          [[end loop]] 
          [[loop SubList2]] 
               [[Title]] 
               [[Firstname]] 
          [[end loop]] 
[[end loop]]

 

[[loop]]
     [[Title]]
          [[loop SubListTitle]]
               [[Title]]
               [[Firstname]]
                    [[loop SubListTitleOfSublist]] 
                         [[Title]] 
                         [[Firstname]] 
                    [[end loop]]
          [[end loop]] 
[[end loop]]

Loops over table rowsIt is possible to loop over table rows by adding the loop inside the table. In the case of nested loops, if the loop on the parent list is placed into the external table, this will render a separate table for each parent item[[loop
SubListTitle]]
[[Title]] [[Firstname]] [[Lastname]]
[[end loop]] 

[[loop]] [[Title]]
[[Title]] [[Firstname]] [[Lastname]]
[[end loop]] 
[[end loop]]
Image

Show an image inside the document.
You can optionally specify the static width and height of the image and also a max/min width and height.
Width/height parameters are not mandatory; they can be '' (empty string) or null. 

Note: [[image...]] placeholder works only with images on current Site for Scheduled & Triggered actions

[[image ([[Picture]], width, height, maxwidth, maxheight, minwidth, minheight)]] 

Without width and height: [[image ([[Picture]])]] 

Static width and height: [[image ([[Picture]], 50, 50)]]   

Static width: [[image ([[Picture]], 20)]] 

Static height: [[image ([[Picture]],,150)]] [[image ([[Picture]], '', '', 100, 300)]]

[[image ([[Picture]], maxwidth=100, maxheight=300)]]

[[image (url=[[Picture]], maxwidth=100, maxheight=300)]]
LinkCreate a link in the document

[[link ([[Hyperlink]])]]

[[link ([[Hyperlink.Url]], [[Hyperlink.Description]])]]

 

[[link (url=[[Hyperlink.Url]], text='linktext')]]

HTML

Allow to insert HTML content inside the document. Supported [[html placeholder]] and placeholder of Multiple lines of text fields with options: Rich text and Enhanced rich text.

Supported tags: <b>, <i>, <u>, <ul>, <ol>, <li>, <span>, <div>, <p>, <h1-h6>, <br>, <a>, <table>, <img>.

Allow to insert inline into html placeholder.
Note: Bulleted and numbered lists, table are not supported when use inline option

[[html ([[@Variable.CustomHTML]])]]

[[RichTextField]],

[[EnhancedRichTextField]]

 

[[html ([[Column]], inline=true)]],

[[html ([[Column]], true)]]