Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Contents

Table of Contents

Email Templates

Email templates represent one of the first features of this app. Its initial implementation only allowed for simple variables to be injected into the templates. They are now based SIL Template Language and therefore their usage got a lot easier than before.

...

Make sure you read sendEmail() routine documentation to see how it is called, and notice that it has many overloads.

Mail Templates Base Directory

Unlike usual templates, presented before, email templates got their own base directory, and you can configure that directory here. This is both for historical reasons and because we recognized the importance of organizing mail templates in our integration projects. Under this directory, you may organize language folders, which will be used to internationalize your email messages. This feature is controlled in the above configuration screen (Mail language on: Receiver). The default is set on Sender which simply uses the declared language of the sender user, whoever s/he may be.

...

Note
titleAdvice

If you need to send the same mail in multiple languages, do not mix templates used with the executeTemplate() routine with the sendEmail() routine. Keep them separate. Of course this is valid only if templates are different, if you use the same for both emails and something else, put them in the same place.

 

Additional Injected Variables

In addition to the variables from the context, sendEmail routine defines a few more variables,  injected into the topmost context, as strings in your template:

  1. recipient - the recipient (s) - if there are more than 1 recipient, recipients are joined together with a comma between them

  2. sender - the sender - but only if the sender is defined.

Usage Examples

Do you have cookies?

To exemplify the usage, let's write a post function:

...

Variables from our script are exposed into the template (cookie seems unused, but it is not!). This template must run in an issue context, since it refers the pre-defined variables from the issue.

Bruce Wayne

Let's try to categorize our customers on either Batman's side, the evil side or neutral side. If we create a customfield customerId, which is a numeric code provided by the user, the following postfunction will complete a variable (custName) with the company name. In production systems, I suppose, you may want to get that customer name from a database (see the sql() routine). For this example, a bit of logic will allow us to distinguish between the Batman's owned corporation and ... eh, a phantom, evil, one:

...