Technical templates

Introduction to technical templates in ConSol CM

Templates are boilerplates consisting of text and code. They are used in several places in ConSol CM, most importantly to define display names and draft emails.

Concepts, terms and definitions

Concept

Other terms

Definition

template

 

Generic concept which includes display templates, text templates and document templates.

display template

data representation template

Template which determines the display names of contacts, resources and users.

email template

 

Template used for emails. This can be a technical template if it is intended to be used in automatic emails only. Otherwise, it must be a text template.

system template

 

Technical template created automatically during system setup or update

Freemarker

 

Template engine used for creating templates in ConSol CM.

Purpose and usage

Templates have several purposes in ConSol CM. They are used to define the display name of contacts, resources and users, and to store boilerplates for automatic emails sent by the system.

A ConSol CM standard installation already contains system templates and some example templates which help you to define new templates for your special use cases.

Templates are written in Freemarker (see https://freemarker.apache.org/). Some types of templates can include HTML tags.

This section describes the technical templates which are managed in the Web Admin Suite. You can find information about the templates which are managed in the Web Client in Text templates. The following template lists the available template types:

Type

Description

Email

Used for emails, both manual emails written in the Web Client and automatic emails sent by the workflow. See Text templates for manual emails. Templates for automatic emails are described in Editing email templates.

Contact

Determines the display name of the contacts, see Adding contact and resource templates.

Resource

Determines the display name of the resources, see Adding contact and resource templates.

User

Determines the display name of the users, see Editing system templates.

Password reset

Used for the email which is sent when a user resets his password for the Web Client or CM/Track, see Password reset.

Representation

Used for the emails which are sent to the affected users when there are changes to representations, see Editing system templates.

Assignment

Used for the emails which are sent to the users when they are assigned to cases, see Case assignment.

Available settings for templates

A template has three settings:

Basic tasks

Finding a template

The list of templates is displayed directly after accessing the Templates page of the Web Admin Suite. You can filter the list to locate a template more easily:

Working with templates

You can perform the following actions on templates:

Adding contact and resource templates

The display name of contacts and resources in the Web Client needs to be defined using templates. The template determines which data fields are used for the display name.

Data fields are referenced by their field group name and field name:

You can create the code with the template generator by clicking the Template generator icon in the editor header and selecting the desired fields.

Do not use line breaks inside the statements which define the display name.

The templates are assigned to the contact objects and resource types in the respective data models.

Advanced tasks

Using the template editor features

The template editor has the following features:

You can see where a template is used by clicking the Usage button. The popup window lists the places where the template is referenced and provides links to jump to the referencing objects.

Using templates in scripts

You can use the following methods to reference templates in scripts, for example to send an automatic email in a workflow activity.

Editing system templates

A default ConSol CM installation comes with several system templates:

The following variables are available in the notification when a representation is created or deleted. “representing” indicates the user who represents another user and “represented” indicates the user who is represented by another user.

Editing email templates

There are a number of occasions where emails are sent automatically by ConSol CM. The content of these emails is defined in email templates. The following sections describe the email templates which need to be defined in the Web Admin Suite. You can define more email templates for your specific use cases in the Web Admin Suite or Web Client.

Email templates which should be available for manually sent emails need to be defined in the Web Client.

Case assignment

Users are notified in automatic emails when a case is assigned to them or they are unassigned from a case. There is a template for each event (assign and unassign) which is referenced in the respective queue (see Queues).

By default, the email address of the CM administrator (see system property cmas-core-security, admin.email) is used as From address. You can set the From address explicitly within the template (see following example).

The following example shows a case assignment template:

Subject: Ticket #${ticket.name} assigned to you

From: cm@example.com

 

<#setting number_format="0.######"/>

The ticket #${ticket.name}

 

"${ticket.subject}"

 

has been assigned to you by <#if engineer_exec??>${engineer_exec.name}<#else>the workflow</#if> <#if engineer_old??>(former engineer: ${engineer_old.name})<#else>(no former engineer)</#if>

 

Please take care.

 

URL: ${urlWebclient}/ticket/name/${ticket.name}

Code example 17: Content of an assignment template

Password reset

If database authentication is used (see Authentication), the users can reset their passwords in both the Web Client and CM/Track. An email template containing a link to the password reset page needs to be defined for each client.

Web Client

When a user has forgotten his Web Client password, he can request a new password by using the Forgot your password? link on the login page. An email with a link to an URL where the user can set the new password is sent to the user.

A valid email address must be set for the user on the Users page.

The template with the email content has to be called password-reset-template. The following example shows a simple template to reset the Web Client password.

Subject: Password reset procedure

From: no-reply@consol.de

 

Dear ${engineer.firstname} ${engineer.lastname},

Please click the following link to reset your password:

 

${urlWebclient}/passwordChange?resetCode=${resetCode}

 

This link expires at ${expirationDate?string("yyyy.MM.dd HH:mm:ss")}.

Code example 18: Template to reset the password for the Web Client

The following variable is configured using system properties:

The From address of the email is defined in the system property cmas-core-security, password.reset.mail.from.

CM/Track

When a contact has forgotten his CM/Track password, he can request a new password by using the Forgot your password? link on the login page. An email with a link to an URL where the contact can set the new password is sent to the contact.

A valid email address must be set for the contact in the respective data field in the Web Client.

The template with the email content has to be called track-password-reset-template. It needs to be created manually. The following example shows a simple template to reset the CM/Track password.

Subject: Your Password Reset Link

From: no-reply@consol.de

 

Dear ${unit.firstname} ${unit.lastname},

Please click the following link to reset your password:

 

${urlTrack}/#/password-reset/resetCode-${resetCode}

 

This link expires at ${expirationDate?string("yyyy.MM.dd HH:mm:ss")}.

Figure 8: Template to reset the password for CM/Track

The following variables are configured using system properties:

Syntax examples

Localizing list values

It is possible to display localized values of enumerated lists in templates by using the localize() method. This method retrieves the localized list value as defined in the Web Admin Suite to display it in the Web Client. Otherwise, the internal list value would be displayed.

The following example shows a template for a resource. The resource field SLA_country is an enumerated list containing countries. The localize() method is used to display the country name in the browser locale.

${localize(resource.getFieldValue("SLA_Fields_basic","SLA_country"))!}

Abbreviating values

It is possible to abbreviate the values retrieved by a template using the abbreviate() method. In this way, long values are shortened, so all fields are displayed even if the first field contains a long value.

The abbreviate() method needs two parameters:

The following example shows the template for a company and how the abbreviated company name is displayed in the case list.

${abbreviate(ResellerCompany.getFieldValue("ResellerCompanyData","company_name"),8)!} - ${ResellerCompany.getFieldValue("ResellerCompanyData","company_number")!}

Using links

You can use the methods linkInWebClientTo() and linkInTrackTo() to add links to cases, contacts and resources to a template. The following methods are available:

The following example shows how to use these methods:

[#assign ticketUrl = "${linkInWebClientTo(ticket)}"]

<p>This is a link to ticket: <a href="${ticketUrl?no_esc}">ticket</a></p>

Handling missing values

You can use if statements in combination with the ?? operator or the ?has_content operator to check if an object exists or a field has a value.

<#if ResellerCustomer.getFieldValue("ResellerCustomerData","customer_name")?has_content &&
ResellerCustomer.getFieldValue("ResellerCustomerData","firstname")?has_content>
${ResellerCustomer.getFieldValue("ResellerCustomerData","customer_name")!},
${ResellerCustomer.getFieldValue("ResellerCustomerData","firstname")!}
<#else> ${ResellerCustomer.getFieldValue("ResellerCustomerData","customer_name")!}</#if>

Code example 19: Example of a contact template with if statement (has to be written in one line!)

Alternatively, you can specify a default value using the ! operator to avoid exceptions due to missing values. The default value can be empty.

${ResellerCompany.getFieldValue("ResellerCompanyData","company_name")!} - ${ResellerCompany.getFieldValue("ResellerCompanyData","company_number")!}

Code example 20: Example of a contact template with empty default value (has to be written in one line!)

Setting number format patterns

Freemarker allows to set a number format pattern. The following example shows a pattern which displays two decimal places for numbers.

<#setting number_format="0.##"/>${customerModelCompany.getFieldValue("groupName", "numberValueField")!}

Code example 21: Setting a number format, so only two decimal places are displayed