Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Job Queue Entries error notification in business central

Posted on by 44

When we have  status an error in Job Queue Entries send mail to notify me in the business central

Categories:
  • ManishS Profile Picture
    ManishS 6,578 on at
    Job Queue Entries error notification in business central
    As suggested by @KasparsSemjonovs this is a great method, this is mainly used for audit purpose, but you can also use it to monitor of status.
  • Job Queue Entries error notification in business central
    What happens if an error occurs when sending an email?
  • Suggested answer
    KasparsSemjonovs Profile Picture
    KasparsSemjonovs 3,680 Super User 2024 Season 2 on at
    RE: Job Queue Entries error notification in business central

    You should be able to use "Field monitoring" functionality, to monitor the Job Queue status, and send You notification when it changes to Error.

  • Suggested answer
    Vaishnavi J Profile Picture
    Vaishnavi J 3,052 on at
    RE: Job Queue Entries error notification in business central

    Hi

    You can customize below is the logic which you can use it

    codeunit 50020 SendNotifification
    {
        trigger OnRun()
        var
           
            JobQueue: Record "Job Queue Entry";
            GetJobQueueDetails: Text[2048];
        begin
            Clear(JobQueue);
            JobQueue.Reset();
            JobQueue.SetRange("Object Type to Run", JobQueue."Object Type to Run"::Codeunit);
            JobQueue.SetFilter("Object ID to Run", '50003..50020');
            JobQueue.SetRange(Status, JobQueue.Status::Error);
            if JobQueue.FindSet() then
                repeat
                    GetJobQueueDetails += Format(JobQueue."Object ID to Run") + ' ' + JobQueue."Object Caption to Run";
                until JobQueue.Next() = 0;

            if GetJobQueueDetails <> '' then begin
                SentMails(JobQueue, GetJobQueueDetails)
            end;
        end;


        local procedure SentMails(var JobQueue: Record "Job Queue Entry"; var Details: Text[2048])
        var
            Rec_UserSetup: Record "User Setup";
            MailingList: List of [Text];
            CU_Email: Codeunit Email;
            CU_EmailMessage: Codeunit "Email Message";
            SubjectLbl: Label 'Job Queue Failed in Business Central';
            BodyLblDeptHod: Label 'Hi IT Team, <br> <br> This is to inform you in Business Central some of the job queue failed. <br> Kindly view the failed job queue %1 this by visiting <a href="%2"> </a> here.';
            AppLink: Text;

        begin
            Clear(AppLink);
            Clear(Rec_UserSetup);
            Rec_UserSetup.Reset();

            Rec_UserSetup.SetRange("IT Department", true);
            if Rec_UserSetup.FindSet() then
                repeat
                    if Rec_UserSetup."E-Mail" <> '' then
                        MailingList.Add(Rec_UserSetup."E-Mail");
                until Rec_UserSetup.Next() = 0;
            AppLink := GetUrl(ClientType::Web, CompanyName, ObjectType::Page, Page::"Job Queue Entries", JobQueue, true);

            if MailingList.Count <> 0 then begin
                Clear(CU_EmailMessage);
                CU_EmailMessage.Create(MailingList,
                                        StrSubstNo(SubjectLbl),
                                        StrSubstNo(BodyLblDeptHod, Details, AppLink), true);

                CU_Email.Send(CU_EmailMessage);
            end;
        end;



    }
    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,349 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,212 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans