Document Templates: Placeholder Syntax | Teamsware

πŸ“„ Document Templates in Teamsware Studio – the Placeholder Syntax

Word and Excel templates fill themselves with list data in Teamsware Studio. This overview shows the syntax for formatting values, inserting images and links, repeating records and applying conditions.

Document creation runs through a triggered action: you store a Word or Excel template containing placeholders, and when the action fires they are replaced with the values of the given record. Placeholders always sit inside double square brackets.


🎯 At a Glance

[[Feldname]] inserts a value – the basic building block of every template.

[[{ … }]] wraps a function when the value needs formatting or calculating before output.

For repetition and conditions there are the blocks [[loop]] und [[if]] – each with its matching closing tag.

πŸ’‘ The basic idea

Simple placeholder β†’ insert the value unchanged

Function β†’ prepare the value before output (currency, date, percentage …)

Block β†’ output several records or tie content to a condition

πŸ”’ How do I format numbers and dates?

Raw values from a list are rarely formatted the way they should appear in the document. A function prepares them:

PurposeSyntax
Currency with two decimals and euro sign[[{return [[WaehrungAuto]].toFixed(2).replace(".", ",") + " €"}]]
Format a date[[{return [[Datum]].format("yyyy-MM-dd")}]]
Percentage with sign[[{return parseFloat(([[ZahlProzentsatz]]*100).toFixed(4)).toString().replace(".", ",") + " %"}]]

The .replace(".", ",") produces the German decimal comma – without this step the value appears with a dot.

πŸ”— How do I output lookup and choice fields?

For a lookup field simply append a dot and the internal name of the column you want:

[[Lookup.Title]]
[[Lookup.Besitzer]]

A multi-choice field returns several values. To show them readably on one line, join them with a separator:

[[{return [[MultiAuswahl]].join("; ")}]]

Images are embedded through the image function – either at original size, at a fixed size or capped at a maximum size:

PurposeSyntax
Insert an image[[image ([[Picture]])]]
Set width and height[[image ([[Picture]], 50, 50)]]
Cap the maximum size[[image ([[Picture]], maxwidth=100, maxheight=300)]]

For links you decide whether just the URL, a link text from the field or a fixed text should appear:

PurposeSyntax
Link only[[link ([[Hyperlink]])]]
Link with link text from the field[[link ([[Hyperlink.Url]], [[Hyperlink.Description]])]]
Manually specified link text[[link (url=[[Hyperlink.Url]], text='linktext')]]

πŸ“ How do I carry over formatted text?

Rich text fields contain HTML formatting. To preserve it in the document – instead of showing it as code – output the field through the html function:

[[html ([[@Variables.CustomHTML]])]]
[[RichTextField]]
[[EnhancedRichTextField]]
[[html ([[Column]], inline=true)]]
[[html ([[Column]], true)]]

With inline=true the content is placed into the running text instead of creating its own paragraph.

βž• How do I build a total?

To sum values from another list, retrieve them with a query and add them up inside the function:

[[{ var arr = [[@Web.GetValuesForQuery('OtherList', '<View></View>', 'Total')]]; var sum = 0; arr.forEach(n=>sum +=n); return sum; }]]

You provide the list name, the CAML query narrowing the records and the column to read.

πŸ” How do I output several records?

With [[loop]] you repeat a section for each record. Loops can also be nested – for example to output the related items for each case:

Nested loops

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

Every loop needs its own [[end loop]]. Without a sublist specified, the loop runs over the records of the main list.

πŸ’‘ Loops inside tables

If each record should produce a table row, place [[loop]] und [[end loop]] inside the row that should be repeated:

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

The row is then generated once per record – the table formatting stays intact.

❓ How do I tie content to conditions?

With [[if]] a section only appears when the condition is met. Otherwise the spot stays empty in the document.

ConditionSyntax
Value 1 greater than value 2 (direct comparison)[[if [[Budget]] > [[Outgoings]] ]]
[[Title]]
[[end if]]
Value 1 greater than value 2 (as a function)[[if {return ([[Wert1]] > [[Wert2]]);} ]]
[[Title]]
[[end if]]
Choice does not equal a text[[if [[Auswahl]]!="Auswahl1" ]]
[[Title]]
[[end if]]
Yes/no field is set[[if [[JANein]]==true ]]
[[Title]]
[[end if]]

Both notations for the comparison produce the same result. The variant using {return …} makes sense when the condition grows more complex and several checks need combining.

πŸ“‹ What does this look like in a Word template?

In the template the placeholders sit directly in the running text or in table cells – exactly where the value should later appear. Formatting such as font, size and emphasis is taken from the template by Teamsware Studio.

🎯 Positioning for everyday use

🎯 Teamsware recommendation

Build templates step by step instead of inserting all placeholders at once. That way an error is found right where it was introduced.

  • βœ… Start with the simple placeholders and test them, then add formatting, and finally loops and conditions.
  • βœ… Always format numbers and dates – otherwise raw values appear with a dot instead of a comma, or in the technical date format.
  • βœ… Use the internal column names, not the display names – a frequent stumbling block with lookup fields in particular.
  • ⚠️ Make sure every [[loop]]- und [[if]]block is closed properly.

πŸ’‘ Quick reminder

[[Feld]] = insert a value

[[{ … }]] = prepare a value

[[loop]] … [[end loop]] = repeat

[[if]] … [[end if]] = only when the condition applies

⚠️ Avoid these common mistakes

  • Leaving a [[loop]]- oder [[if]]block open – the template then cannot be processed correctly
  • Using the display name instead of the internal column name
  • Outputting numbers without formatting and getting a dot instead of a comma
  • Using rich text fields without the html function – the HTML code then appears as visible text
  • Placing the loop outside the row that should be repeated in tables
  • Forgetting the dot and the target column on lookup fields

Teamsware GmbH · Leopoldstraße 31 · 80802 München · www.teamsware.eu