We already have a mechanism to customise workflow mails via Scriptlets.
Because Scriptlets are not very useful for complex scripting we now added an alternative way.
Specify a mail-config TMLScript module with name "mailconfig.tmlscript" in Folder wga/workflow. This script should return an JS-Object that may have the following properties (all optional):
- mimeType (String)
- createMailSubject(op) (Function returning a String)
- createMailBody(op) (Function returning a String)
If present the custom functions "createMailSubject" and "createMailBody" will be called with an "op" parameter specifying the current Operation. Possible values are:
- APPROVAL_REQUEST
- RELEASED
- REJECTED
In addition the following vars are provided:
- replacereason
- comment
- approvalurl
Sample using handlebars templates to create the mail body:
return {
mimeType: "text/html",
createMailSubject: function(op){
var subject={
APPROVAL_REQUEST: "Document '" + TITLE + "': approval requested",
RELEASED: "Document '" + TITLE + "': approved",
REJECTED: "Document '" + TITLE + "': rejected"
}
return subject[op];
},
createMailBody: function(op){
var content = AFW.Handlebars.fileTemplate("overlay:workflow", op.toLowerCase()+".txt", context("this"));
return AFW.Handlebars.fileTemplate("overlay:workflow", "layout.html", {
body: content,
footer: WGACore.releaseString
})
}
}