Nav Email Template Changes

In Nav 2016 you can now setup email notifications for a variety of things. These emails start off as a template. This post I wanted to look at changing these templates to add in more things. At first glace is seems like you can only have one template active per type (approval, new record, etc..) By modifying the base templates you can add a lot more options to give them the flexibility to work with a large range of records.

To view your templates run page 1510 (Notification Templates). From here you can export and import any html templates. Exporting any of the default templates and opening them up in an web browser, you can see that they use a bunch of tokens. Most of these tokens are words wrapped in percent signs. Example %DocumentNo%. These tokens are replaced with data just before the email gets send out. The following is an export of the default approval email template.

Untitled

To makes changes to the template you can create, change or delete tokens in the html template. Once you make your changes be sure to import them back in. ¬†For changes to the code, open up codeunit 1510, Notification Management. In here you should see a bunch of functions start with “Replace” or “Populate”. These are the functions that replace all the tokens in the template with actual values. To minimize changes within this codeunit, you could add in events that fire after each of these functions. This way you can make your custom changes outside the base objects.

There are a few helper functions in the same codeunit that makes replacing the tokens a lot easier. SetTokenToValueOfField will grab the proper value of the field and format it properly depending on the field type.

Hopefully this gets you started with modifying the base templates. Remember that the emails are in html. So you can add in a lot of formatting and CSS to give them a custom look for your clients installation.

One thought on “Nav Email Template Changes

Leave a Comment