Skip to main content
Skip table of contents

Content (Velocity)

The content for Task Reminder emails is written with HTML and the Velocity templating language. This language provides a few simple language constructs like loops (#foreach) and conditionals (#if/#elseif/#else) that should be sufficient to write any kind of email body. Additional to the generic Velocity language functionality, we offer a templating API for Task Reminder.

Velocity API

The following variables are available in email content templates:

  • $user (Object) - object for the user receiving this email

    • $user.fullName - The full name of the user

    • $user.email - The email address of the user

    • $user.name - The Confluence user name of the user

  • $dateTool (Object) - an instance of the Velocity DateTool that provides you a set of tools for dealing with dates

  • $baseUrl (String) - the base URL of your Confluence instance. For example, if you view pages with URLs like https://your.domain.com/pages/viewpage.action?pageId=10000000, the base URL will be https://your.domain.com/

  • $whatIsSoonInDays (Number) - this will be the numeric value you configured in General Settings for tasks to be categorized as expiring soon.

  • $tasks (Structure) - this is the main data structure containing a list of tasks for the categories Expired, Expiring Soon, Expiring Later, and Tasks without due date. Each of these lists has a boolean field activated that is true if the category is currently enabled in the general settings (with the respective toggle button). Furthermore, the amount of tasks in each list can be retrieved by calling $list.size().

    • $tasks.expired - list of open expired tasks for the user

    • $tasks.expired.activated - true if these should be included in emails

    • $tasks.expiringSoon - list of open tasks expiring soon (i.e. within the date range configured in settings)

    • $tasks.expiringSoon.activated - true if these should be included in emails

    • $tasks.expiringLater - list of open tasks expiring later (i.e. later than the date range configured in settings)

    • $tasks.expiringLater.activated - true if these should be included in emails

    • $tasks.withoutDueDate - list of open tasks that don't have a due date

    • $tasks.withoutDueDate.activated - true if these should be included in emails

Each task in one of the list of tasks described above will be an object with the following fields:

  • $task.pageId (Number) - the ID of the page where the task is on

  • $task.body (String) - the task content (i.e. what's written next to the task as the actual TODO)

  • $task.dueDate (Date) - the due date of the task (null if task has no due date)

    • Note: this can be used in combination with the $TR.formatDate helper method described below!

  • $task.pageTitle (String) - the title of the page where the task lives

  • $task.creator (Object) - the object for the creator of this task

    • $task.creator.fullName (String) - The full name of the creator

    • $task.creator.email (String) - The email address of the creator

    • $task.creator.name (String) - The Confluence user name of the creator

  • $task.spaceKey – The key of the space where the task was found

  • $task.spaceName – The name of the space where the task was found

The Task Reminder Helper

There is a helper object with utility methods that you can access in your template with the $TR key. Currently the following methods are available:

  • $TR.getText(propertyKey: String) - retrieve a translated property using the user's configured language (see Task Reminder Email Translations (i18n properties))

    • Example: $TR.getText("my.property.key")

  • $TR.formatDate(dateFormat: String, date: Date) - format a given date with the given date format string

    • Example: $TR.formatDate("yyyy/MM/dd", $task.dueDate) - e.g. 2019/10/31

Note: these are only the methods we have implemented so far because we needed them for the default template. Please let us know if you would like another method by raising a feature request!

The Default Template

The default template currently looks as follows. Once again, check the Velocity docs to find out how to write templates in this language.

CODE
## DEFAULT EMAIL CONTENT

<h2>Your open tasks</h2>

<p class="intro">Hi $user.fullName! Here is today's list of open tasks for you.</p>

#set($dateFormat = "dd MMM yyyy")

#if ($tasks.expired.activated && $tasks.expired.size() > 0)
  <h3>Expired Tasks</h3>
  <ul id="tasks-expired">
    #foreach($task in $tasks.expired)
      <li>
        <span class="date">$TR.formatDate($dateFormat, $task.dueDate) </span>
        <span class="task-body">$task.body</span><span> - </span>
        <a class="task-page" href="$baseUrl/pages/viewpage.action?pageId=$task.pageId">$task.pageTitle</a>
      </li>
    #end
  </ul>
#end

#if ($tasks.expiringSoon.activated && $tasks.expiringSoon.size() > 0)
  <h3>Tasks expiring within the next $whatIsSoonInDays days</h3>
  <ul id="tasks-expiring-soon">
    #foreach($task in $tasks.expiringSoon)
      <li>
        <span class="date">$TR.formatDate($dateFormat, $task.dueDate) </span>
        <span class="task-body">$task.body</span><span> - </span>
        <a class="task-page" href="$baseUrl/pages/viewpage.action?pageId=$task.pageId">$task.pageTitle</a>
      </li>
    #end
  </ul>
#end

#if ($tasks.expiringLater.activated && $tasks.expiringLater.size() > 0)
  <h3>Tasks expiring after the next $whatIsSoonInDays days</h3>
  <ul id="tasks-expiring-later">
    #foreach($task in $tasks.expiringLater)
      <li>
        <span class="date">$TR.formatDate($dateFormat, $task.dueDate) </span>
        <span class="task-body">$task.body</span><span> - </span>
        <a class="task-page" href="$baseUrl/pages/viewpage.action?pageId=$task.pageId">$task.pageTitle</a>
      </li>
    #end
  </ul>
#end

#if ($tasks.withoutDueDate.activated && $tasks.withoutDueDate.size() > 0)
  <h3>Tasks without due date</h3>
  <ul id="tasks-without-due-date">
    #foreach($task in $tasks.withoutDueDate)
      <li>
        <span class="task-body">$task.body</span><span> - </span>
        <a class="task-page" href="$baseUrl/pages/viewpage.action?pageId=$task.pageId">$task.pageTitle</a>
      </li>
    #end
  </ul>
#end

<p class="manage"><a href="$baseUrl/plugins/inlinetasks/mytasks.action">Manage my tasks</a></p>

<div class="regards">
    <span>Yours sincerely,</span>
    <span>Task Reminder for Confluence</span>
</div>
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.