Customizing Emails

By default WorkflowFirst creates an email that contains a link to the workflow record, details of the current state of the record's fields in a tabular format.

Sometimes you want to customize how that email is displayed. The top of the email can be controlled through the workflow stage's description. However if you want more control than that, you can either send the email yourself using the workflow stage's script, or you can add something called a Notification Template.

To do this, first make sure that the workflow settings have Notification By Stage set to Yes (it is turned off by default):

After publishing, in your application go to the Configuration tab, and in the hamburger icon menu you'll see an entry called "Notification Templates". Click add in that area.

The list of events should correspond with the stages of different workflows in the system. Select the one you want to customize.

Now the subject and body entries can contain plain HTML. However, that HTML can contain markup that lets you incorporate values from the current record (applicable to the workflow).

The markup takes two forms. You can use tilde (~) to surround a field name in the record and it will be replaced with the value of that field. For example, ~Originator~.

Alternatively you can use dollar signs to repeat an area for sub-records, for example $Items$ Item name: ~Name~, price ~Price~. $end$.

Notice the $end$ to terminate the block. Everything between the $Items$ and $end$ will be repeated for each record in the sub-form, Items.

Both of these commands can incorporate DbfScript expressions, if they start with an equals sign. For example:

~=#input/Price * #input/Quantity~

Anything after the equals sign is a DbfScript expression, where #input is the associated record in the database and &path is the path of the location in the database. For example you can do this:

$=load(&path/Items)$
$end$

...to load the Items under the record in the database, and repeat that block for each entry.

Keep in mind that the notification templates are cached for performance reasons, and so sometimes changes may require either restarting the application (republishing) or waiting 5 minutes for the change to be picked up.

Also keep in mind that any errors in the template can cause notifications to be disabled, so care should be taken to test the changes before using them in a production environment.


Next Topic:
v4.2.0.956 (beta)
Up Since 2/29/2024 12:02:23 AM