# Get started with Template Designer

## Create a Template

Navigate to your **Workspace > Apps** and click on the gear icon <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBCeOhqzSg8dBSFcJSA%2F-MBCo7T7BtG64Zwffv31%2Ffa-cog.png?alt=media&#x26;token=7b190f6b-19e5-4dea-8eaa-3bf0e53fa641" alt="" data-size="line"> to activate the configuration mode of your apps. Next, click on the gear icon <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBCeOhqzSg8dBSFcJSA%2F-MBCo7T7BtG64Zwffv31%2Ffa-cog.png?alt=media&#x26;token=7b190f6b-19e5-4dea-8eaa-3bf0e53fa641" alt="" data-size="line"> of the app you want to configure. In the **Views** section you click on **Templates** to access the Template Designer. Click **New Template**.

![Create a new template in the Template Designer](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ1zgYEoXtuAS6qdzMK%2F-MJ20GQbv4hLczMx4UPD%2FTemplate_GettingStarted.gif?alt=media\&token=93512b67-9a22-48a8-a74c-e040fe867156)

A template contains various sections to detail the purpose and content of the document. The following paragraphs describe each section in details.

## General

Every template needs some general information about its purpose. Those properties are defined in the **General** section of a template.

### Key

Optionally, you can give your query a Key or match code. This property can be helpful in other drop-down or selection menus in your app to quickly access and choose a template. In the list of templates the value of Key is shown in parentheses behind the name of the template.

{% hint style="info" %}
The Key is a unique distinction between templates which is displayed in the Template Designer, but will not be visible to the end user in the finished app.
{% endhint %}

### Name

The name of the template with that it is represented.

![Templates can be given a language-specific name](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ35lWEjNUdhhrYNzIc%2F-MJ38Y-TIHW9wQ3LvFHK%2FTemplate_Name_Localisation.png?alt=media\&token=25073f34-5607-448f-9419-0daa6dd3d949)

Using the globe symbol <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ25m2_xbj5pRzElG6G%2F-MJ25re9x9fYnQmQ2O6J%2Ffa-globe.png?alt=media&#x26;token=55c4c701-5e6f-471c-8cf7-3b9f1480460e" alt="" data-size="line"> on the right-hand side allows you to add or modify language-specific values of the property. Click again on the globe symbol <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ25m2_xbj5pRzElG6G%2F-MJ25re9x9fYnQmQ2O6J%2Ffa-globe.png?alt=media&#x26;token=55c4c701-5e6f-471c-8cf7-3b9f1480460e" alt="" data-size="line"> to collapse the section.

### Description

Provide fellow users a description of the template to explain what the template is designed for.

![Description of a template in multiple languages](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ35lWEjNUdhhrYNzIc%2F-MJ391iwcxSPbN8V6tG2%2FTemplate_Description_Localisation.png?alt=media\&token=141f2511-f028-4afb-8432-e2f286ffed4b)

Using the globe symbol <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ25m2_xbj5pRzElG6G%2F-MJ25re9x9fYnQmQ2O6J%2Ffa-globe.png?alt=media&#x26;token=55c4c701-5e6f-471c-8cf7-3b9f1480460e" alt="" data-size="line">on the right-hand side allows you to add or modify language-specific values of the property. Click again on the globe symbol <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ25m2_xbj5pRzElG6G%2F-MJ25re9x9fYnQmQ2O6J%2Ffa-globe.png?alt=media&#x26;token=55c4c701-5e6f-471c-8cf7-3b9f1480460e" alt="" data-size="line"> to collapse the section.

## Template

### Class

A template is valid for one class. Choose for which one.

![Choose a Class to assign to the template](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ35lWEjNUdhhrYNzIc%2F-MJ3A7enLiZWyvn-Cb4D%2FTemplate_Class.png?alt=media\&token=30e6662a-6976-4f25-8772-f586c67f3d69)

{% hint style="info" %}
You have to specify a Class to validate your template.
{% endhint %}

### Valid On

A template can be applied on a class, which means on all instances at once or on one instance only.

### Template Script

To create an individualized template, the Template Designer allows users to specify scripts that create and enable the template execution. For more information on how to work with scripts on TIVITY see the documentation for the [Script Designer](https://docs.tivity.one/building-an-application/execution/scripting).

In the Script for the template the variable that are replacing the placeholders in the document must be defined. Therefore, they must be named and spelled exactly the same way. Within this script, it must be defined how these data fields are filed.&#x20;

For example, which data is used for the variables. As explained in the documentation on the Script Designer, different data inputs can be used and expressions for calculating and evaluating variables can be defined. This way a sophisticated report or form letter can be created.

## Document

A template can be classified based on the following three types: Internal Document, External Document, or External Placeholder.

![Specify the document type used in the template](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3IMTPz1fDQ1rGnU2J%2F-MJ3JADpWtVQvbdw7We6%2FTemplate_Document.png?alt=media\&token=f1745d83-c56a-40ce-be62-ceb542827ad5)

### Internal Document

Create a document as template within the TIVITY platform by using a Script.

**Internal Documents** are created within the TIVITY platform. Use this type if only a script is used to return the needed Information. You don’t need to upload a document with placeholder instead create a script and the return of the script will automatically convert to a PDF.

### External Document

Upload a Word document as template. Therefore add placeholders in this document, so the designer can fill them out with data entries from the platform.

**External Documents** are Word documents that can be created outside of the platform and then be uploaded in the Template Designer. When the Template Designer is executed, it then automatically checks the document for placeholders and replaces them with the related data in the platform. Then, a new Word document is created with the new data inside.

![Attach an external document to the template](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3M-LZk0dl5AruWIoC%2F-MJ3MV0eP2vn6VOqRKiM%2FTemplate_Document_External.png?alt=media\&token=fda0a3da-dc54-4716-94ed-53ba9bd7d391)

Click on the <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3M-LZk0dl5AruWIoC%2F-MJ3NxozowxJb3_etueu%2Ffa-upload.png?alt=media&#x26;token=a684e612-59e6-4485-b39b-95653861ee52" alt="" data-size="line"> Upload icon to upload a new external document. To check the document of a template, click on the <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3M-LZk0dl5AruWIoC%2F-MJ3O1o-bbcE5GVZt_KN%2Ffa-download.png?alt=media&#x26;token=edf33e35-afc9-4585-a71a-4d7c7c9bacec" alt="" data-size="line">  Download icon to download it.

### External Placeholder

Upload a PDF document with form fields and fill this fields with values from an Instance. Using a script to match PDF form fields with internal fields.

Use **External Placeholder** if there is a PDF document with form fields which should be filled with values from an instance. Upload a document with form fields, after that click on <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBjhTlYxxRF8b7FkWx_%2F-MBjrqDntQEvPrUZw3N9%2Ffa-cubes.png?alt=media&#x26;token=765845d9-1d21-4fe4-ab77-df971c11b8eb" alt="" data-size="line"> Open script icon. The form fields of the PDF documents will be displayed as variables in the script. Inside the script fill these variables with internal values. After that you can use the template and the platform will file the form fields with the values according to the instance and create a PDF document.&#x20;

![Assign external placeholders via a document to the template](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3O5gO6NKvknl9-RP-%2F-MJ3Oc0GZGKfw4Npi56v%2FTemplate_Document_Placeholder.png?alt=media\&token=acbd6a0d-9312-486f-b018-760d36187e10)

Click on the <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3M-LZk0dl5AruWIoC%2F-MJ3NxozowxJb3_etueu%2Ffa-upload.png?alt=media&#x26;token=a684e612-59e6-4485-b39b-95653861ee52" alt="" data-size="line"> Upload icon to upload a new external placeholder document. To check the placeholder document of a template, click on the <img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3M-LZk0dl5AruWIoC%2F-MJ3O1o-bbcE5GVZt_KN%2Ffa-download.png?alt=media&#x26;token=edf33e35-afc9-4585-a71a-4d7c7c9bacec" alt="" data-size="line">  Download icon to download it.

## Advanced

### Parent Template

To enable the inheritance of templates, a parent template can be chosen among the existing templates within the app.

![Templates can be derived from another template](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ3Qb3SWADaaSsgRZhJ%2F-MJ3SauarcPWjp3D0KKb%2FTemplate_Advanced.png?alt=media\&token=566be756-d0d5-49f9-a80b-5ef840968b5e)

{% hint style="danger" %}
Inheritance is not available for External Placeholder templates.
{% endhint %}

## Parameters

Add Parameters that will requested when the Template is used. You can use parameters to hand over variables to a workflow/function that is used in the template.

Every template can have assigned specific parameters. These are variables that can be utilized within the template script. Here, different input or output variables for executing the template can be defined.

![Use parameters to customise your template](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ6Kqjx24-BJFmfiPsb%2F-MJ6MS46yf6yWtqseMDr%2FTemplate_Parameters.png?alt=media\&token=84cd7370-9f0b-43bd-8857-8f79dd3b3353)

In the properties of a parameter, various points can be defined. Next to the name and description the variable type can be defined or whether this field is required before execution, its default value and what error message is prompted otherwise.

![Edit properties of a template parameter with more details](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MJ6Kqjx24-BJFmfiPsb%2F-MJ6O4-CBlbcU7k8KpqW%2FTemplate_Parameters_Property.png?alt=media\&token=7ba826c9-c2e0-4714-86ef-c66adaf642c5)

### Control type

The available types are described in more detail in [Data Modelling](https://docs.tivity.one/building-an-application/data/data-modelling) under page [Field](https://docs.tivity.one/building-an-application/data/data-modelling/field).

{% content-ref url="../../data/data-modelling/field" %}
[field](https://docs.tivity.one/building-an-application/data/data-modelling/field)
{% endcontent-ref %}

## Validate and Save a Template

The validation automatically checks whether the settings of the template are valid and provides notifications when there are errors.

Finally, click on **Validate** to verify that your selection of criteria is accepted by the Template Designer. Click on **Save** to store your template and return back to the list of templates in your app.
