How do I make AX send an alert email every time a batch job executes?
I know how to make it send an email when I change the status to waiting or withheld.
I would like to be able to set up alerts when jobs exe, error, and so on.
How do I make AX send an alert email every time a batch job executes?
I know how to make it send an email when I change the status to waiting or withheld.
I would like to be able to set up alerts when jobs exe, error, and so on.
I don't think standard alerts will work, but you could put custom code in the BatchRun
class. I wouldn't recommend it, but instead I'd suggest you create a very simple batch process that monitors whatever batch tasks you want to monitor.
If you must put code in, it looks like there are several processes that can change a Batch
or BatchJob
to executing, and you'd have to examine the logic more closely:
\Classes\BatchRun\serverGetTask
\Classes\BatchRun\do
\Classes\BatchRun\serverGetOneTask
As this is not a standard option, the easy way would for the job to send the mail itself.
There are several ways to send email, SysEmailTable::sendMail comes handy:
SysEmailTable::sendMail('templateId',
'en-us', // Chosen language
'WhoYouSendThisTo@example.com', // Who you're sending the email to
mappings, // Your variable mappings
'', // Location of file attachment (server/client matters) or none
'' , // XML if you're using XSLT
true, // Traceable or not?
'admin', // Sending user
true); // Use retries?
See this blog for more information.