Wednesday, November 16, 2011

How Alerts in AX work with templates and emails

Alerts in AX can be very useful, and I wanted to touch on how they work, along with some explanations, tips, and tricks.  Much of this post is basic, but there are some caveats explained as well.  I mainly use alerts to notify a user when a field or record is created, modified, deleted, etc.  A user specifically wanted to know whenever a credit limit changed for a this is the scenario I will be covering.

You first need to make sure you have an alert email template setup.  This can be done from Basic>Setup>Email Templates.  Here you will create your header alert record, and your line records are for different languages should you need them.

After you create the basic one as pictured, you click the "Template" button where you define your template.  I suggest putting in the following HTML code under the HTML tab from

You then need to configure the alerts parameters at Basic>Setup>Alerts.  You want to choose the "Alerts" email id template you just created.

The "Drill-down target" can be confusing...but here is my interpretation of it.  You basically put something different for each of your AX environments (Dev/Test/Prod).  When you have an alert email sent automatically with hyperlinks, it will be something like Dynamics://DEV... (instead of http://DEV...) that will be clickable, and open an AX client and go directly to the alert or the alert's origin.

When you click the link, it basically tries to go to your default client config, and then it confirms that the "DEV" found in the URL also is found in the alerts setup.  If it is not, it just doesn't open the client.  So if you are getting alerts from Dev/Test/Prod, only the ones that have the correct Dynamics://[this part] will work.  This obviously means you must have a local client installed.

The types of alerts:
  • Changed based alerts
    • Alerts that occur when something changes, like a customer name, or customer credit limit
  • Due date alerts
    • Alerts that occur when something is due, typically workflow related

These both have batch jobs, located at Basic>Periodic>Alerts that should be running in order to actually create the alerts that meet the rule criteria.  If you aren't getting the alert bell pictures in the lower corner of your session, then one of these is probably not running correctly.

Now let's setup the alert rule to notify us when the credit limit has changed for a customer.  You can set alerts on anything pretty much you right click on.  Go to your customer details form, then the general tab, then right click on the credit limit field and click "Create alert rule" as pictured:

Now base AX only lets you alert one user.  You can create a user that has a distribution list for an email account, or you can do some simple modifications in X++ to support overwriting the alert email, or alerting multiple emails/users.  For now, you can just click OK here and then close the window behind it.

If we go to a customer and change their credit rating, an alert will be generated (provided the batch is running as stated earlier or it is run manually).

For the email portion, the way alerts are setup is to have traceable emails.  So what it does is dump it into an email sending queue that can be found at Administration>Periodic>E-mail processing>E-mail sending status.

This emailing subsystem is very handy, and open for many useful modifications if you're feeling creative.  Emails in this queue are picked up for delivery by the e-mail processing batch, which is located at Administration>Periodic>E-mail processing>Batch.  This must be running for the emails to go out.

You can view sent emails with the body of the message, and also resend them should you choose to do so.

There is also a retry schedule that is located in the same place where you can set your retry intervals for failed email attempts.

The framework is here behind the scenes to open it up for some very useful modifications.  For example, if you periodically email customers a survey, and you want to send them reminders to fill it out, or you are waiting for any other sort of user input and you want to send emails until they perform their action.

This just briefly outlines and touches on alerts and emails.  If you have any questions, feel free to comment.  I will be elaborating on email templates later on.


  1. Hi!

    In this example you are creating alert rule on a field what if I want to create alert rule on the click of a button.

  2. Hi, how i can setup reminders? for example: for
    unsettled purchase & sales invoices for accounts department? we would like the reminder to stay till the said purchase
    & Sales invoices are settled.


    someone wants to get reminder for journal for its posting. system should keep reminding the user unless he has posted the JV.

    please advise.

  3. Hi,
    I have a requirement in which I have to run some process to write the data into file through a runbasebatch a class because it should run in batch. But my requirement is when I add the class into batch and if there is any error occurred during batch processing, an email should go to the specific user. And the template is defined by the email template. So for that,

    -I created a Batch Group;

    - I created a template e-mail and I linked to the Batch Group created;

    - I configured the Email parameters;

    - I configured the Alert parameters;

    - I started the Alert batch process with the Batch Group created;

    - I started the Email processing with the Batch Group created;

    - I started the Batch processing;

    - I created the Alert Rule in batch job history table and I gave start in it.

    The pop up appears, and the email also comes but the email which is coming is nothing but the alert message. But it is not showing my email template message. it is always showing the standard message "The batch job CheckTest completed successfully".

    where checkTest is the name/description of the batch job.

    Please suggest.


    1. What I understand you are asking for is an email notification when a batch job completes, but the job executed fails. The only way I could figure out how to do this was to create a table that would store the error log (use ReqLog table as example). I added another boolean field to indicate that the log field was not empty on record insert. Then I set alert to email when the Boolean field was true.

  4. Additionally, Is there any way to put 'Modified By' user or 'Last Action Taken By' user or something relevant.

    Thanks in advance for prompt response.

    1. Easily! Just modify `\Classes\EventActionEmail\createEmailParameterMap` and add additional parameters you want displayed, then modify your template to include the %parameter% so it is displayed.

  5. where can I find %parameter% defined to use in the HTML template?

    1. "%parameter%" is just any placeholder you want. It could be "%MyName%". You need to define it in `\Classes\EventActionEmail\createEmailParameterMap` where the lines say parameterMap.insert('MyName', 'Saan Jones');. This is where you can expose additional variables of your choosing.

      I cover the details of parameter maps in this blog post too if you want more information

    2. Thanks Alex. The link below in your message comes with the message "Sorry, the page you were looking for in this blog does not exist." Any help.

    3. I am trying for a shipment status event. It picks the shipment number but I am interested in pulling the purchase order number and the line description on the email template. How is it possible?Do I need to define this in the createEmailParameterMap ?Any help would be helpful.

  6. Hi Alex

    How do I get an alert if a customer has been set up with an empty field, ie, I want to know that the Site has been left blank. I tried to set the event on the field to 'is set to' and then left the fileld blank. I've also tried "", and ' '.