Templates
This page covers advanced TIVITY template features: image handling, language settings, and custom functions for dynamic and powerful document generation.
Last updated
This page covers advanced TIVITY template features: image handling, language settings, and custom functions for dynamic and powerful document generation.
Last updated
The Templates area within the Team app of a workspace has been removed. It is no longer possible to overwrite templates via the team app. If it is necessary to overwrite templates for an app, the app creators are now obliged to offer this function in their app themselves.
For templates that use an external document of type Word, it is possible to include images in the template.
To do this, a variable must be created in the template script which contains the image to be used. The image can then be retrieved in the Word template via a placeholder ({VariableName}).
The image formats BMP, GIF, JPEG, PNG and TIFF are supported. Other documents (like text documents) cannot be inserted and throw an error.
Example configuration
Script:
Word:
Result:
Even if the context instance contains an image, this cannot be included with the context placeholder (example {Context.Document}). In this case, a new variable would still have to be created in the script to which the document is transferred with the "GetDocument" script action.
Templates for the external documents Words can provide additional resizing formatting. Supported image formats can be resized by width and height, preserving the aspect ratio (uniform) or not (fill) using a format
Width and height: {Placeholder:imageresize(<Stretch>,<Width-Value><Width-Unit>/<Height-Value><Height-Unit>)}
Width-only: {Placeholder:imageresize(<Stretch>,<Width-Value><Width-Unit>/)}
Height-only: {Placeholder:imageresize(<Stretch>,/<Height-Value><Height-Unit>)}
Stretch uniform preserves the aspect ratio when resizing the image. Width or height are resized to the given value while preserving the aspect ratio for the missing value. When both width and height are given, then the image is resized to fit the given dimension while preserving the aspect ratio.
Stretch fill does not preserve the aspect ratio when resizing the image. Width and/ or height are resized to the given value.
The following units are supported:
pt: points as is
cm: converted to points
inch: converted to points
imageresize(uniform,1cm/) for an image of 2cm/4cm: resizes the image to 1cm width and 2cm height
imageresize(uniform,1cm/1cm) for an image of 2cm/4cm: resizes the image to 0.5cm width and 1cm height
imageresize(fill,/1cm) for an image of 2cm/4cm: resizes the image to 2cm width and 1cm height
imageresize(fill,1cm/1cm) for an image of 2cm/4cm: resizes the image to 1cm width and 1cm height
Unsupported stretch, missing values, unsupported units or other malformed input throw an error.
If a template is executed, the language of the executing user is used by default.
If placeholders with formatting are used. These are then formatted depending on the template language.
Example: DE: {Context.DueDate:dddd} --> Mittwoch EN: {Context.DueDate:dddd} --> Wednesday
If the template is executed via a workflow using the script action "ExecuteTemplate2", the language with which the template is executed can be specified, regardless of the user settings.
When no language is passed, then the format of the expression is executed with the language of the executing user.
When the script of a template is executed, then a variable with the passed or evaluated language is available through the name 'Context.TemplateLanguage'.
It is possible to execute functions within a template and pass parameters to the function.
Syntax:
Example:
Given a function 'Name' has a parameter 'Parameter1' and 'Parameter2' and a template has the expression '{Function.Name(Parameter1:"Value1",Parameter2:"Value2")}', when the template is executed, then the function 'Name' is executed with "Value1" passed for 'Parameter1' and "Value2" passed for 'Parameter2'.
If only one parameter is passed, the value from the context is evaluated for the other parameter. If parameters are passed that are not present in the function, these are ignored and the missing parameters are evaluated with the values from the context.
Given a function 'Name' has a parameter 'Parameter1' and 'Parameter2' and a template has the expression '{Function.Name()}' or '{Function.Name}', when the template is executed, then the function 'Name' is executed with the value for 'Parameter1' and 'Parameter2' evaluated from the context.
💡 For more information on context evaluated values for parameters, see the following documentation: Expressions in Condition Values - Docs (tivity.one)
Given a template has an expression with a wrong syntax, when the template is executed, then an error message is shown (including the syntactically wrong expression).
Given a template has an expression with parameters and a format, when the template is executed, then the function is executed, parameters are passed and the return value is formatted.
Given a template has an expression without parameters and a format, when the template is executed, then the function is executed and the return value is formatted (current behavior).
Data Types of Values:
Given a parameter value is surrounded by double-quotes ('{Function.Name(Parameter1:"Value1"}'), when the expression is executed, then the value is passed as a string. Double-quotes '"' can be escaped with a backslash '\'. Backslashes '\' can be escaped with a backslash '\'.
Other data types (variables, integer, DateTime, etc.) are currently not supported