# Templates

### Overwriting templates with the Team app has been removed.

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.

### Use images in templates

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:

<figure><img src="/files/FOdN7ryhWEJ65rze9jsM" alt=""><figcaption><p>Script Configuration</p></figcaption></figure>

Word:

<figure><img src="/files/lysIo6nDXHu08Ikivthe" alt=""><figcaption><p>Word Template</p></figcaption></figure>

Result:

<figure><img src="/files/fF70K5DuaCt5g7FEkby5" alt=""><figcaption></figcaption></figure>

### **Limitation**

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.

### Resize images in templates

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

#### **Examples:**

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

### Execute template in a specific language

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'.

### Functions with parameters in templates

It is possible to execute functions within a template and pass parameters to the function.

**Syntax:**

```csharp
{Function.Name[([Parameter1:"Value1"[,Parameter2:"Value2"]])][:Format]}
```

**Example**:

```csharp
{Function.GetInitialState(ItemType:"Task",IncludeArchivedStates:"False")}
```

Given a function 'Name' has a parameter 'Parameter1' and 'Parameter2' and a template has the expression '{[Function.Name](http://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](http://Function.Name)()}' or '{[Function.Name](http://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)](https://docs.tivity.one/building-an-application/expressions/expressions-in-condition-values)

### **Syntax Error**

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).

### **Formatting**

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](http://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**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tivity.one/platform-features/templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
