Velocity Templates

As part of issue computation, instead of providing a plain description, you can define velocity templates to generate well-formatted messages for the Alert inbox or to be sent as an email.

Velocity templates can be added in the <module_base_package>/mpt/custom/templates/<model_name>/alerts/ folder and used from your Issue computation code. For example:

@Override
public void execute(PersonalizedIssueCompContext<Shipment> compContext) throws Exception {
//Add logic to check if an issue to be generated or not
Issue issue = compContext.getCurrent().issueOn(ShipmentConstants.Issues.SHIPMENT_UPDATE_ALERT, IssueSeverity.HIGH);
compContext.setSubjectTemplate("shipment_update_alert_subject.vm");
compContext.setBodyTemplate("shipment_update_alert_message.vm");
 
compContext.setEmailSubjectTemplate("shipment_update_alert_subject.vm");
compContext.setEmailTemplate("shipment_update_alert_subject.vm");
}

This provides a "default" implementation of alerts for modules. But often, we have a requirement to override this at the instance level or at the EPT level. Please refer to the next section for details.

Velocity Template Override

Velocity templates can be overridden by project teams by creating a new VM template with the same name as the original VM template and placing it on the shared file system.

If the template location in ZBKS module for Book model is com/onenetwork/mybooks/mpt/custom/Standard_ZBKS_Book/alerts/Book_Message.vm, Platform checks for an override template in <shared_file_system>/vm-templates/Standard_ZBKS_Book/alerts/Book_Message.vm

EPT developers can also override templates by putting it in <EPT_base_package>/vm-templates/Standard_ZBKS_Book/alerts/Book_Message.vm