Email Templates: Difference between revisions

From Obsidian Scheduler
Jump to navigationJump to search
Line 46: Line 46:
| warnOrHigher || Boolean || Always || Indicates if the level was <code>FATAL</code>, <code>ERROR</code> or <code>WARNING</code>.
| warnOrHigher || Boolean || Always || Indicates if the level was <code>FATAL</code>, <code>ERROR</code> or <code>WARNING</code>.
|-
|-
| INFO || Boolean || Always || Indicates if the level was <code>INFO</code>.
| info || Boolean || Always || Indicates if the level was <code>INFO</code>.
|-
| job || Complex Object || Job Events only || For any job-related category, this field is populated. Attributes that can be accessed on the job are: <code>id</code>, <code>jobClss</code>, <code>minExecutionDuration</code>, <code>maxExecutionDuration</code>, <code>nickname</code>, <code>pickupBufferMinutes</code> and <code>recoveryType</code>.
|}
|}



Revision as of 01:48, 3 June 2013

As of version 2.0, Obsidian supports customizable templates for all email notifications.

Template Basics

Obsidian comes with two basic email templates that are suitable for most users. For those that wish to have more control, templates can be configured in the Email Templates screen.

Both subject and body fields can be templated. Note that body templates are used for HTML only.

Templating Language

Obsidian email templates use Mustache, which is a logic-less templating language commonly used in various applications. Specifically, Obsidian uses jMustache, and it can be referred to when looking for feature support and general syntax in your templates.

Templating Variables

The following table documents all data elements that are available in email templates. Note that some data elements are only available in certain contexts, so your templates should be written accordingly. The Available Scope column indicates what types of events the variable is used in. For example, some variables are only present for job-related event categories, and some are only present for Job Run events.

If you wish to see a sample template, simply navigate to the Email Templates screen in the admin UI, and take a look at the default templates that are pre-installed.

Variable Name Type Available Scope Notes
subject Text Always This the basic event summary message.
detailItems Text (multiple) Always The list of all detail messages provided with the event. For example, when a job's configuration is updated, a separate item for each change will be represented here. In some cases, this may be empty.
detail Text Always This the combined form of detailItems. In some cases, this may be empty.
hostName Text Always The host name / designator that originated the event.
hostUrl Text Always The host URL as configured in the Systems tab. This can be used to link to the Obsidian installation in emails.
hasDetail Boolean Always Indicates if any detailItems exist. Can be used for conditionals.
level Text Always Indicates the level of the event. One of: INFO, WARNING, ERROR, FATAL.
recipients Text (multiple) Always The email addresses of all recipients of this message.
fatal Boolean Always Indicates if the level was FATAL.
error Boolean Always Indicates if the level was ERROR.
errorOrHigher Boolean Always Indicates if the level was FATAL or ERROR.
warn Boolean Always Indicates if the level was WARNING.
warnOrHigher Boolean Always Indicates if the level was FATAL, ERROR or WARNING.
info Boolean Always Indicates if the level was INFO.
job Complex Object Job Events only For any job-related category, this field is populated. Attributes that can be accessed on the job are: id, jobClss, minExecutionDuration, maxExecutionDuration, nickname, pickupBufferMinutes and recoveryType.

Sample Syntax

The following shows various ways data can be accessed from within an Obsidian email template. This example lacks HTML formatting and is meant to show how to access and display different variables available to your templates.

Current Job Schedule: {{currentSchedule}}
Detail: {{detail}}
{{#detailItems}}
Detail {{-index}}: {{.}}
{{/detailItems}}
Error: {{#error}}true{{/error}}{{^error}}false{{/error}}
Error or Higher: {{#errorOrHigher}}true{{/errorOrHigher}}{{^errorOrHigher}}false{{/errorOrHigher}}
Fatal: {{#fatal}}true{{/fatal}}{{^fatal}}false{{/fatal}}
Warn: {{#warn}}true{{/warn}}{{^warn}}false{{/warn}}
Warn or Higher: {{#warnOrHigher}}true{{/warnOrHigher}}{{^warnOrHigher}}false{{/warnOrHigher}}
Info: {{#info}}true{{/info}}{{^info}}false{{/info}}
Host Name: {{hostName}}
Host Url: {{hostUrl}}
Level: {{level}}
Recipients: {{#recipients}}{{^-first}}, {{/-first}}{{.}}{{/recipients}}
Subject: {{subject}}
Job: {{#job}}{{id}} {{nickname}} {{pickupBufferMinutes}} {{recoveryType}} {{jobClass}} {{minExecutionDuration}} {{maxExecutionDuration}}{{/job}}
Job State: {{#jobState}}{{effectiveDate}}-{{endDate}} {{jobStatus}} {{schedule}}{{/jobState}}
Job History: {{#jobHistory}}{{adHoc}} {{resubmission}} {{scheduledTime}} {{submissionMode}} {{runningHost}}{{#chainedFrom}}; Chained from: {{this.job.nickname}} ({{this.scheduledTime}}){{/chainedFrom}}{{/jobHistory}}
Job Results: {{#jobResults}}{{^-first}}; {{/-first}}{{key}}={{#value}}{{^-first}}, {{/-first}}{{.}}{{/value}}{{/jobResults}}
Job Results by Name: {{#jobResultMap}}{{#result1}}{{^-first}}, {{/-first}}{{.}}{{/result1}}{{/jobResultMap}}
Job Results by Name (short): {{#jobResultMap.result2}}{{.}}{{/jobResultMap.result2}}
Job Parameters: {{#jobParameters}}{{^-first}}; {{/-first}}{{key}}={{#value}}{{^-first}}, {{/-first}}{{.}}{{/value}}{{/jobParameters}}
Job Parameters by Name: {{#jobParameterMap}}{{#param1}}{{^-first}}, {{/-first}}{{.}}{{/param1}}{{/jobParameterMap}}
Job Parameters by Name (short): {{#jobParameterMap.param2}}{{.}}{{/jobParameterMap.param2}}