How to get failed job queues directly on your mail?
When I was working for the end customer, one of the daily jobs for one of the consultants, was to check if all job queues in all databases and all companies were not stopped by some error.
I thought, why cannot we get the notification whenever the Job Queue is stopped? That would save us a lot of time.
What are the solutions?
Almost five years later this is still not a standard feature in Business Central. And apparently, we will not get it soon (Check this idea Microsoft Idea · Job Queue failure notification (dynamics.com))
So what instead? I know the partners who try to solve this issue with custom development. Also, I have seen at least three apps on AppSource that solves the issue.
However, I believe that this should be a standard feature in Business Central and the customers should not pay for it (at least for the basic solution).
Is there any other option?
Let’s see if we can do something without (or with a minimum) AL development.
The answer could be already hidden in the idea that I showed you above – the telemetry. But the problem, that the author pointed, is that the telemetry is only for the administrators. But is it? Can we use it somehow to send the notifications?
Telemetry Signal – AL0000E26
The Telemetry for Business Central allows getting information about the failed Job Queue Entries. You can get it with below KQL.
traces
| where customDimensions.eventId in (“AL0000E26”) and customDimensions.aadTenantId !in (“default”, “common”, “”) and
customDimensions.alJobQueueResult == “Fail”
| project [‘Date’] = timestamp, alJobQueueCompanyName = customDimensions.alJobQueueCompanyName,
alJobQueueExecutionTimeInMs = customDimensions.alJobQueueExecutionTimeInMs,
alJobQueueId = customDimensions.alJobQueueId,
alJobQueueObjectId = customDimensions.alJobQueueObjectId,
alJobQueueObjectType = customDimensions.alJobQueueObjectType,
alJobQueueResult = customDimensions.alJobQueueResult,
alJobQueueScheduledTaskId = customDimensions.alJobQueueScheduledTaskId,
alJobQueueStatus = customDimensions.alJobQueueStatus,
environmentName = customDimensions.environmentName,
environmentType = customDimensions.environmentType
You can send the mail using the Alerts in Application Insights but I am aware that is more technical and not everyone has access there.
Power Automate Flow
Instead of that, I want to propose an easy Power Automate Flow. The flow would allow you to send notifications to anyone in the way you need – mail, Teams, or even WhatsUp message. Application Id and Access Key are the only things that you need to connect to Application Insights.
Import the Flow
You can download the flow here and import it to your Power Automate. Please remember that Application Insights requires a premium connector.
How does it work?
We will run the query every 1 hour, however, you can set your recurrence (for example every 15 min).
Then, for a more comfortable setup, we will initialize the Email parameters such as Address (use “;” to send messages to more people – for example, consultant or customer), Subject, and Body.
In the last section, we will set Signals and KustoQuery. You do not need to change anything here if you do not know the KQL.
Later flow checks if there are any records and cancel the flow if there is nothing. If any record has been found then the mail is sent. You can add also other notifications if needed.
Works…
… but I cannot see the error message. That is true. Some time ago I spoke with Microsoft people and the error message can contain GDPR sensitive data. This is the reason why in the telemetry signal we cannot have error text. To be honest, I hope this state will change soon with plans for new telemetry signals in April 2022.
If not let me know if you want to do more – get an error message or even automatically restart the queue.
This is good – I implemented it in a few minutes. I am thinking about adding a step to call an API to grab the error log. What are your thoughts?
Hi. Thx. Yes I also was thinking about it and now when I know we will not get it from MS I will prepare all and will write a second part of the blog how to do it. But need to find some time for that.
Hi Krzysztof,
Take a look into our free app – Xtbc Job Queue Monitor. We also had this problem, so we created this app 🙂
https://appsource.microsoft.com/en-us/product/dynamics-365-business-central/PUBID.xtbc|AID.xtb_jqm|PAPPID.5c04d6dd-4068-4452-a57c-fa133edae8b8?tab=Overview
Hi Krzysztof, importing the solution in Power Apps gives an error:
The solution file is invalid. The compressed file must contain the following files at its root: solution.xml, customizations.xml, and [Content_Types].xml. Customization files exported from previous versions of Microsoft Dynamics 365 are not supported.
Hi Krzysztof,
Thanks for putting the article together. I have been playing with this for hours to try and get it triggering.
My flow is in a constant state of “Cancelled”. Even though Job Queue’s would of errored within the hour. Any thoughts? Surely if the API/Application Insight Instruction key was wrong in Admin Centre, it would fail?
Any pointers appreciated?
Thanks,
Ciarán