Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Event subscriber not working

(0) ShareShare
ReportReport
Posted on by 257

Hi, I am subscribing an event of codeunit 449 -  Job Queue Start Codeunit. But I am not getting my required result. for example inset a record in custom table.

Here is my code

EventSubscriberInstance = StaticAutomatic;

    [EventSubscriber(ObjectType::Codeunit449'OnAfterRun''', true, true)]
    procedure abd(JobQueueEntry: Record "Job Queue Entry")
    begin
        Message(StrSubstNo('%1', JobQueueEntry.Status));
    end;
  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    13,209 Moderator on at
    RE: Event subscriber not working

    The job queue runs in the background, so you will not get any message pop-up.

    If you want to capture the error log, you need to subscribe to the right event.

    Check codeunit 450 "Job Queue Error Handler".

  • Danyal Profile Picture
    257 on at
    RE: Event subscriber not working

    I have tried onAfterInsert and OnAfterValidate, onAfterModify but seems these triggers are not getting any hit.

    Just tried onBeforMarkAsError, but nothing happened

  • Suggested answer
    Bilal Haider Profile Picture
    234 on at
    RE: Event subscriber not working

    The event that you have mentioned in example code will run after a JobQueue is started. I do not know your exact requirements but I think you need to subscribe an event when an entry is created in Job Queue Log Entry table. If that is the case then use event like OnAfterInsert or there are many other events available for Job Queue Log Entry table. One potential event that you can use is OnBeforeMarkAsError.

    Hopefully this will help you.

    Regards,

    Bilal Haider

  • Danyal Profile Picture
    257 on at
    RE: Event subscriber not working

    Inserting record in a custom table was just an example, this can be anything, for example generating emails etc.

    So I want to generate an email or create custom logs whenever a job goes to error. Can I use the event which I mentioned? or is there any other way?

  • Bilal Haider Profile Picture
    234 on at
    RE: Event subscriber not working

    Hi Danyal,

    What do you mean by insert a record in custom table? and what is its relation to Job Queue Start codeunit's event OnAfterRun.

    Please add more detail to it.

    Regards,

    Bilal Haider

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,002 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans