Text templates

Introduction to text templates in ConSol CM

Text templates are boilerplates consisting of text and variables, which allow to automatically insert data of the current user or case. They are used in emails and comments. Text templates help to keep emails consistent regarding wording and layout, and increase the productivity of the users who do not have to type as much text.

Concepts, terms and definitions

Concept

Other terms

Definition

text template

 

Template which is used when writing emails or comments.

document template

Office template

Microsoft Office or OpenOffice file used as a template for CM/Doc.

Freemarker

 

Template engine used for creating templates in ConSol CM.

Purpose and usage

Text templates facilitate the work of the Web Client users by providing them with drafts for emails and comments. In addition, the text of automatic emails or automatically added comments can be stored in text templates.

Text templates can include variables which are filled with data from the case where the template is used. Variables can retrieve case data, data of the case’s contact or assignee, and data of the current user.

When using a text template, the template content is inserted into the comment or email editor. The user can edit it as desired to create the final comment or email. It is possible to use several templates for a comment or email.

Text templates are saved on the Text templates page of the Web Client. Templates which are only used in the workflow and should not be available for selection in the Web Client, can also be saved on the Templates page of the Web Admin Suite.

Available settings for templates

Text templates have the following general settings:

If a template uses data fields which are no longer available, the line of the respective template is displayed in red on the overview screen. The broken references are displayed in red and you need to remove them to be able to save the template.

Types of templates

There are four types of text templates. A text template is always of one of the types.

Template usage

There are four places where text templates of the type Letter can be used. You can select one or several of the places:

For text templates of the type Include, there is one setting:

Basic tasks

Finding a text template

The list of text templates is displayed directly after accessing the Text templates screen of the Web Client. You can filter the list to locate a template more easily:

You can select the checkbox Include inactive templates if you want to display disabled templates as well.

Managing text templates

You need to have the Manage templates permission or administrator permissions to manage templates, see Global permissions.

Best practice

Set up a specific role for the users in charge of the text and document templates. Create a role with the permission Manage templates only and assign it to the users who create or edit templates.

Most actions to manage templates can be accessed from two places:

The following actions are available for templates:

Writing text templates

You can perform the following steps to write a text template:

  1. Create a template of the type Letter. You can enter text and format it using the rich text editor. In addition you can insert variables from the library of template fields. See Using variables in text templates. You can add attachments to the template. If the template should only be available in specific queues or if specific data fields are filled out in the case, you can restrict the template accordingly. See Binding a text template.

    Alternatively, you can create a new template from an outgoing email in the case history. Click the entry Use as template in the context menu of the email to open the template creation screen.

  2. Optional. Add attachments to the letter. When selecting the template in the comment or email editor, the attachments are preselected. They are attached to the case upon saving the comment or sending the email. When an email template with attachments is used by the workflow, the attachments are ignored.
  3. Optional. Create a template of the type Text block. You can enter text and format it using the rich text editor. See Using variables in text templates.
  4. Optional. Create a template of the type Include. You can enter text and format it using the rich text editor. In addition you can insert variables from the library of template fields. See Using variables in text templates. You can use all kinds of variables except for text blocks and other includes. A common use case for includes is the email signature, which is added to all letters used for emails.
  5. Optional, administrator permissions required. Create a template of the type Script. You can enter text and use Freemarker code to add logic. If you select the Allow HTML checkbox, you can use HTML tags to format the script content.
  6. Optional. Reference text blocks, includes and scripts in the letter. See Using variables in text templates.

It is not possible to use executable JavaScript code in text templates. Any <script> tags are escaped automatically by the system.

You can view the source code of the template by clicking the Code view button in the rich text editor.

Using variables in text templates

The library of template fields allows to insert variables into text templates. There are four kinds of variables:

The following table lists the available variables with a short description. Different colors are used in the template administration to make it easier to distinguish between the different kinds of variables.

Variable

Description

Color

Customer data models

Allows to insert contact fields. Select the customer group and contact object (company or person) to see the available data fields.

Blue

Customer Group

Allows to insert the name of the customer group.

Blue

Queue

Allows to insert the name of the queue.

Blue

Custom fields

Allows to insert case fields. Select the field group to see the available data fields.

Blue

Ticket

Allows to insert basic case data (ID, name, subject, creation date, escalation date). You can click the Engineer option to insert data of the assignee, e.g. the name or phone number (see Users for details about the available fields).

Blue

Engineer

Allows to insert data of the current user, e.g. the name or phone number (see Users for details about the available fields).

Blue

Includes

Allows to insert templates of the type Include.

Orange

Text blocks

Allows to insert templates of the type Text block.

Green

Workflow includes

Allows to insert templates of the type Include which have the option Is workflow checked, so that they can be used in templates which are used in the workflow.

Orange

Scripts

Allows to insert templates of the type Script.

Lila

String parameter

Displays a text field above the comment / email editor where the user can enter a text which is inserted in the configured place within the template.

Red

Enum parameter

Displays a selector above the comment / email editor where the user can select one of the enum values to insert it in the configured place within the template.

Red

Please proceed as follows to insert references to text templates and fields:

  1. Place the cursor at the desired position within the text.
  2. Navigate to the desired item in the Library of template fields section and click to insert the item.

Please proceed as follows to insert parameters:

  1. Place the cursor at the desired position within the text.

  2. Insert the parameter in the Library of template fields section:

    String parameter:

    1. Click Add string parameter.
    2. Enter the name of the parameter in the field below New parameter.
    3. Click Add parameter.

    Enum parameter:

    1. Click Add enum parameter.
    2. Enter the name of the parameter in the field below New parameter.
    3. Select an enum. The checkbox Template enabled needs to be selected for the enum on the Enumerated lists page.
    4. Click Add parameter.

See Using parameters for information about the user perspective.

Binding a text template

The binding determines in which cases a letter template is available. The availability of a text template depends on two factors:

If you do not need all the case fields of the type enum for text templates, you can exclude specific case fields using the page customization of markersLibrary. This improves the load time of the template details page because the excluded field do not need to be loaded in the Binding section.

Using text templates

Text templates can be used in the comment and email editor of the Web Client and in the workflow. Text templates which are used in the workflow work in the same way as regular templates (see Using templates in scripts).

The following section describes how users work with text templates in the Web Client.

The user can select the desired templates in the Add template selector of the comment and email editor. He can edit the template text before saving the comment or sending the email. If a default template is used, the user can remove or edit the content of this template. The template is inserted as text, the text which belongs to variables has the same color as in the template administration. The purpose of the colors is to highlight the parts which are dynamically retrieved, the sent email or saved comment does not have these colors.

The following figure shows a template with two text blocks in the comment editor. Both text blocks are selected, so that they are included in the comment.

Figure 9: Template with text blocks (user perspective)

The following figure shows a template with one string parameter and one enum parameter. The user can provide the desired values above the editor to insert them.

Figure 10: Template with parameters (user perspective)

You can configure several editor settings regarding templates in the page customization of mailTemplate.

Advanced tasks

Using scripts in text templates

Scripts allow to add logic to the templates. They can only be edited by users who have administrator permissions, see Global permissions. Using scripts you can implement for example customized salutations depending on contact fields.

Script templates are written in Freemarker (see https://freemarker.apache.org/). If you select the Allow HTML checkbox, you can use HTML tags to format the script content.

You have to use square brackets [] instead of the angle brackets used in standard Freemarker notation.

Scripts with the option Allow HTML can include links. The links have to start with one of the allowed protocols (http, https, ftp, ftps, file, mailto), otherwise they are removed.

Therefore, you cannot directly use a script function within a link to dynamically retrieve a complete link from a case or contact field. The following code using a function within the link tags in a script will not work:

<a href="${ticket.get('fieldgroup.field')}">My Link</a>

Instead, the field value must not include the protocol. You can use a variable which stores the return value of the function:

[#assign link=ticket.get('fieldgroup.field')!]

<a href="https://${link}">My link</a>

Special case: script which includes template with images

If the script is used to include templates of the type Letter or Include which contain images, you need to proceed as follows:

If the script is used in a template for an automatic email, and the email content should be written to the case history, use the method workflowApi.addTicketTemplateText(String pTemplateName).

Coding example: queue-specific signatures

The following example shows a script template used to include a specific signature depending on the current queue of the case. This way, you can use different signatures for different departments of the company.

[#if ticket.queue.name??]

[#if ticket.queue.name=="ServiceDesk"]

[#include "Signature ServiceDesk"]

[#elseif ticket.queue.name=="HelpDesk_1st_Level"]

[#include "Signature Helpdesk"]

[#else]

[#include "Default signature"]

[/#if]

[#else]

[#include "Default signature"]

[/#if]

Coding example: using lists and tables in templates

Data fields of the type list or struct cannot be selected directly using the library of template fields. Instead, you need to create a script and include it in the letter template. The Allow HTML checkbox needs to be selected for the script template. The following example shows how to write a script which displays the content of the struct order_list in the case field group helpdesk_standard. The table header is displayed in bold font and contains the field names.

[#if helpdesk_standard.order_list?has_content]

<table>

[#list 0..helpdesk_standard.order_list?size-1 as i]

<tr>

[#list helpdesk_standard.order_list[i] as value]

[#if i==0]

<td style="border:1px solid #d9d9d9; padding: 0 2px;font-weight:bold;">${value}</td>

[#else]

<td style="border:1px solid #d9d9d9; padding: 0 2px;">${value}</td>

[/#if]

[/#list]

</tr>

[/#list]

</table>

[/#if]