How to create your own email notification templates

TrackStudio has the features in which you can create and use your own templates for email notifications and subscriptions. Two basic templates viz. text and HTML have been integrated in the package. For many these are sufficient, and some may want to have the templates according to their corporate standards and requirements. Templates in TrackStudio have been developed in the Freemarker markup language. So that you didn’t need to learn this language, we are going to tell you how you can display the basic information from TrackStudio in these templates.

How to change the Subject of E-Mail

It is most convenient to use different official remarks in the subject field of the email. For example, task number and its name.

<#assign Subject="[#${task.number}] ${task.name}"/>

Some important variables:

${task.projectAlias} — project code (indicated in the Code field of the higher task)
${reasonForSubject} — event code. Event may be like:
“Task added”, “Task updated”, “File uploaded”, “Event added”, “Testing”, “Subscription”.
${task.number} — task number
${task.name} — task name
${task.category.name} — task category
${task.status.name} — current status of task 
${task.resolution.name} — task resolution 
${task.priority.name} — task budget 
${task.submitter.name} — task submitter name 
${task.budgetAsString} — task budget 
${task.actualBudgetAsString} — time spent 
${DateFormatter.parse(task.submitdate)} — task create time 
${DateFormatter.parse(task.updatedate)} — task update time 
${DateFormatter.parse(task.closedate)} — task close time (the task, which is not in the final, does not have this value)
${DateFormatter.parse(task.deadline)} — deadline for completion of task

How to change the field “From”

You can change the name of sender of Email as well as his Email ID. For this purpose, variables FromEmail and FromUser need to be defined.

<#if fromUserEmail?exists>
    <#assign FromEmail="${fromUserEmail}"/>
</#if>
<#if fromUserName?exists>
    <#assign FromUser="${fromUserName}"/>
</#if>

Here ${fromUserEmail} and ${fromUserName} are taken from the properties of the user in TrackStudio, though by default first e-mail is taken from the list, if the user has many of them.
You can change these parameters. For example,

<#assign FromEmail="callcenter@domain.com"/>
<#assign FromUser="Call Center"/>

In this case the email will come from "Call Center "

Other fields can also be changed in the same manner. For example ReplyTo:

<#assign ReplyTo="Call Center <callcenter@domain.com>"/>

Or CC (carbon copy)

<#assign CC="Sales Department <sales@domain.com>, IT Department <it@domain.com>"/>

You can similarly change other Headings of the email, by inserting them in Headings, e.g., for using the data from them in special mail clients or handlers.

<#assign Headers={"X-Meta":"data"}/>

How to set the encoding of email

<#assign ContentType="text/plain;\n charset=\"${charset}\""/>

Here ${charset} is defined by the settings of TrackStudio (trackstudio.encoding), but you can assign the encoding you require. In that case the text of template should also have the same encoding.

How to indicate link to the task

Link to your package of TrackStudio is stored in the variable ${link}, correspondingly link to the task will be

{link}/task/${task.number}?thisframe=true — for text template and 
<a href="${link}/task/${task.number}?thisframe"> for HTML template </a>

How to display the description of task

If your template is in HTML format, description will be simply displayed as ${task.description}. For text format you can use

<#if task.textDescription?exists>
${task.textDescription}
</#if>

How to display the value of custom field

${task.udfValues["Header"]}

How to display message list

<#assign taskMessages = Util.getSortedMessages(task)/>
<#if (taskMessages?size>0)>
<#list taskMessages as msg>
   ${DateFormatter.parse(msg.time)}: ${msg.textDescription}


While sending notifications and notes, event code is stored in the variable reason.code. The codes include:

N: New task added
NA: New task added with attached file
M: New message added
MA: New message added with attached file
A: New attached file added
S: Scheduled delivery of subscription
T: Test