当批处理作业状态更改为正在执行时,如何发送电子邮件警报?

How do I send an email alert when batch job status changes to executing?

如何让 AX 在每次执行批处理作业时发送警报电子邮件?

我知道如何让它在我将状态更改为等待或保留时发送电子邮件

我希望能够在作业 exe、错误等情况下设置警报。

我认为标准警报不起作用,但您可以将自定义代码放入 BatchRun class。我不推荐它,但我建议您创建一个非常简单的批处理过程来监视您想要监视的任何批处理任务。

如果您必须放入代码,看起来有几个进程可以将 BatchBatchJob 更改为执行,您必须更仔细地检查逻辑:

  • \Classes\BatchRun\serverGetTask
  • \Classes\BatchRun\do
  • \Classes\BatchRun\serverGetOneTask

由于这不是标准选项,因此作业本身发送邮件的简单方法。

发送邮件有多种方式,SysEmailTable::sendMail派上用场:

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?

有关详细信息,请参阅 this blog