Introduction

A notable limitation in Business Central is the monitoring of Job Queue Entries. Although monitoring encompasses a wide range, I will present a method to receive notifications in a Teams Channel when a Job Queue Entry fails.

To send a notification to Teams from Business Central, I will utilize Power Automate.

alt text

PS> Get-BlogPostStructure -TableOfContents

For Power Automate to receive an event from Business Central, Business Central must raise an External Business Event. Currently, there is no such event available out of the box.

Creating an External Business Event

To generate an External Business Event, I will subscribe to the OnAfterLogError event in the “Job Queue Error Handler” Codeunit and then trigger a new External Business Event.

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Job Queue Error Handler", OnAfterLogError, '', false, false)]
local procedure "Job Queue Error Handler_OnAfterLogError"(var JobQueueEntry: Record "Job Queue Entry")
begin
    OnJobQueueError(JobQueueEntry.SystemId);
end;

[ExternalBusinessEvent('OnJobQueueError', 'On Job Queue Error', 'On Job Queue Error', Enum::EventCategory::"Job Queue Error")]
local procedure OnJobQueueError(JobQueueId: Guid)
begin
end;

The subsequent steps involve subscribing to the Event in Power Automate and forwarding details to Teams regarding the Job Queue Entry that has failed.

Setting Up Power Automate Flow

First, I will present an overview of the Power Automate Flow.

Power Automate Flow Overview

The first step is subscribing to our new External Business Event to start the Flow.

Subscribe to Business Event

Second is to get the URL for the Job Queue Entry Card, to show information for the Job Queue Entry that failed.

Get URL for Job Queue Entry

Third is getting an adaptive card for the Job Queue Entry we can post to Teams. Fields in an adaptive card are defined by the Brick layout for the table.

Get Adaptive Card

Final step is to post the adaptive card to a Teams Channel.

Post to Teams

The Results

When a Job Queue Entry fails, a new post will be made to the specified Teams Channel. It will look like the following:

Teams Notification

Here it is possible to work directly with the Job Queue Entry by clicking the details button.

Job Queue Entry Details

The full source code for this article can be found on my GitHub.