Admin Tool Templates

Introduction to Templates in the Admin Tool

In ConSol CM, several types of templates are used:

In this chapter, the general templates in the navigation item Scripts and Templates of the Admin Tool are explained.

Admin Tool templates are written using FreeMarker notation (see FreeMarker web site) and should only be edited by experienced ConSol CM consultants and administrators. A ConSol CM standard installation already contains system templates and some example templates which might help you, as an administrator, to define new templates for your special use cases.

The Admin Tool Template Editor

To work with templates, open the navigation item Scripts and Templates in the navigation group System and switch to the Template tab.

In the templates list, all templates are listed with:

To open a template in the editor panel, mark it in the list and open it by clicking the Edit button. Each template must have a name, whereas the group name is optional.

If your system works with various languages, you can define each template for each language. Use the drop-down menu Language above the editor panel. The Web Client will display the template for the configured locale of the web browser. If there is no template for this language, the default language will be used. Every template has to be defined for the default language.

Figure 402: ConSol CM Admin Tool - System, Scripts and Templates: Template editor

The Templates screen shows the following items:

Working with Admin Tool Templates

The Admin Tool templates represent a template pool. Each template can be referenced from different modules of the system and is always referenced by its name. In the following paragraphs, all modules where templates can be used are explained. Within a template, the data fields are referenced by group name and field name.

The following example shows how the field company_name within the customer field group ResellerCompanyData is referenced.

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

For a detailed explanation of working with ticket fields, please see section Ticket Fields (Setting Up the Ticket Data Model). Customer fields are explained in section Setting Up the Customer Data Model. Resource fields are explained in section CM/Resource Pool - Setting Up the Basic Resource Model.

Do not use line breaks in template statements!

System Templates

A default ConSol CM installation comes with several system templates. They are used in standard situations like error messages sent to an administrator. Please see the following list for an overview of the system templates:

Templates to Define the Display of Customer and Resource Data in the Web Client

The representation of customer data and resource data, the so called display name, used in the different sections of the Web Client can be defined using templates. The definition has to be made for each customer object and resource type. The template can use the available customer or resource fields for the respective object.

The following example shows the use of a template to format the contact name in the ticket list, so that the first name and last name of the contact are displayed.

Figure 403: ConSol CM Web Client - Example of a customer template (ticket list)

The following template is used:

${ResellerCustomer.getFieldValue("ResellerCustomerData","forename")!} ${ResellerCustomer.getFieldValue("ResellerCustomerData","customer_name")!}

Code example 79: Customer template

Please see Templates for Customer Data and CM/Resource Pool - Templates for Resource Data for detailed information about the available template types and the assignment of the templates.

Localizing Enum Values in Templates

It is possible to display localized enum values in templates by using the localize() method. This method retrieves the localized enum value as defined in the Admin Tool to display it in the Web Client. Otherwise, the technical enum value would be displayed.

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

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

Abbreviating Values in Templates

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 ticket list.

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

Figure 404: ConSol CM Web Client - Abbreviated value in ticket list

Using Links

You can use the methods linkInWebClientTo() and linkInTrackTo() to add links to tickets, customers 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 in Templates

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 for the given customer or resource.

<#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 80: Example of a customer 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 81: Example of a customer template with empty default value (has to be written in one line!)

Setting Number Format Patterns in Templates

Freemarker allows to set a number format pattern.

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

Code example 82: Setting a number format, so only one decimal place is displayed

Ticket Assignment Templates

Engineers are notified in automatic emails when a ticket is assigned to them or they are unassigned from a ticket. The templates used for these emails are called ticket assignment templates.

These templates are defined per queue in the Queues. There are templates for the use cases assign and remove.

You have to write and save the templates in the Template section first. Then they will be available in the drop-down menu in the Ticket assignment templates section of the queue details (see section Queues). You can define a name of your choice - we recommend using a name which describes the use of the template.

As default From address, the email address of the CM administrator (CM system property admin.email) is used. You can also set the from address explicitly within the template (see following example).

The following example shows a ticket assignment template as defined in the Templates section.

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: http://localhost:8080/cm-client/ticket/name/${ticket.name}

Code example 83: Content of an assignment template

Password Reset Templates

When users forgot their passwords, they can request a new password using ConSol CM standard functionality. The user might be an engineer who works with the Web Client or a customer who has a login to CM/Track. For both cases, the administrator has to configure ConSol CM in a way that an email can be sent to the user who needs a new password. This email is based on a template which is stored in the Admin Tool, in the Template section. The email contains a hyperlink to a page where the password reset can be performed.

Password Reset Template for Engineers in the Web Client

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

Please note that this can only work if a valid email account is available for this engineer and if the respective value has been entered as email address for the engineer in the engineer data!

The email which is sent to the engineer is based on the template password-reset-template. This template name is mandatory, required for the password reset to work. The template could look like the following example:

Subject: Password reset procedure

From: no-reply@consol.de

 

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

Please click the following link to reset your password:

 

http://localhost:8888/cm-client/passwordChange?resetCode=${resetCode}

 

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

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

The From address of the email which is sent to the engineer is defined by the CM system property cmas-core-security, password.reset.mail.from.

Figure 405: ConSol CM Web Client - Password reset by an engineer

Please note that the password reset in the Web Client is only possible if the standard mode is used. It is not possible if LDAP or Kerberos authentication is in operation. See section Authentication Methods in ConSol CM for an explanation of all possible authentication modes.

Password Reset Template for Customers Using CM/Track

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

Please note that this can only work if a valid email account is available for this customer and if the respective value has been entered as email address for the customer in the respective customer field.

The email which is sent to the customer is based on the template track-password-reset-template. This template name is mandatory, required for the password reset to work. The template has to be created/added manually, it will not be present in the system by default.

The template should be formatted like the following example (you can add any text you would like to send to your customers, but please note the resetCode variable and the URL!):

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 406: Template to reset the password for CM/Track

The following variables are configured using system properties:

Figure 407: CM/Track - Password reset by a customer

Please note that the password reset in CM/Track is only possible if the DATABASE mode is used. It is not possible if LDAP authentication is in operation. See section Authentication Methods for Customers in CM/Track for an explanation of all possible authentication modes.

Custom-Defined Templates

You can define any template that is required and store it in the Templates tab. The API methods renderTemplate() and mergeAndInlineImages() can be used to reference a template when used in automatic emails which are sent in a workflow activity. However, most email templates should be managed using the Text Template Manager (see section Text Templates). There are only very few use cases which might require that email templates, or parts of email templates, have to be stored in the Templates tab of the Admin Tool.