Skip to content

Email templates

An email template is the body of a message the process sends: the text behind the task notification or the file a trigger names in PMFSendMessage().

Templates belong to the process. Open the process and choose Templates: you can write one in the editor or upload a plain text or HTML file. The file you upload is what the process uses; the editor is a convenience, not a second copy.

Placeholders

The body is text with case variables in it:

<p>Dear @#reqUserName,</p>
<p>Your leave request was approved: @#daysReq days, from @#fromReq to @#toReq.</p>
  • @#Variable inserts the value of the case variable with that name.
  • A variable the case has not stored renders as nothing, not as @#Variable. That is the usual reason a template arrives with a blank line.
  • A trigger can pass extra values in the emailTemplateVariables argument of PMFSendMessage(); they are merged over the case data, so they can also override it.

The value is inserted as text. If the variable holds HTML, it is escaped.

Repeating a grid

A grid is printed with a block that repeats for every row:

<table>
  <tr><th>From</th><th>To</th><th>Days</th></tr>
  @>reqLeaveGrid
  <tr><td>@#detDateFrom</td><td>@#detDateTo</td><td>@#detNoDays</td></tr>
  @<reqLeaveGrid
</table>

Everything between @>reqLeaveGrid and @<reqLeaveGrid is repeated once per row, with that row's columns in place of the placeholders. A block that is never closed swallows the rest of the message — the classic “my email stops after the table” symptom.

Older templates wrap the markers in HTML comments (<!-- @>grid -->), which also works and keeps the markers out of a plain-text mail client. Either form is fine; be consistent inside one template.

Images

An image in a template must be reachable by the recipient, not by the server:

<img src="https://docs.example.com/assets/logo.png" alt="Lurana">

A relative path or a file inside the case does not travel with the email: the recipient sees a broken image.

Sending it

From a trigger:

PMFSendMessage(
    $_SESSION["APPLICATION"],
    "no-reply@example.com",
    @@NotifyTo,
    "",
    "",
    "Leave request approved",
    "leave-approved.html",
    ["daysReq" => @%Days]
);
Position Argument
1 Case id
2 Sender address
3–5 To, cc, bcc — comma separated for several recipients
6 Subject
7 Template file name
8 Extra variables for the template
9 Attachments (full paths)

PMFSendMessageToGroup() sends to a group instead of an address list. Both are in the function reference.

Attaching it to the process

The trigger runs at the moment you choose:

  • before or after a step (form, input or output document);
  • before the case is assigned to the next user;
  • before or after the case is routed.

With a condition, it runs only when the condition is true — for example, send the message only when @@repFinalDec is 0, so the applicant gets one email and not one per step.

Before you rely on it

  • Send it to yourself with a real case: placeholders and grid blocks look different with real data.
  • Keep the template small. Long HTML with external CSS is often stripped by mail clients.
  • The message is recorded in the message history; the case keeps the copy, so “did the email go out?” has an answer.