Skip to main content
Business Central forum
Suggested answer

Job Queue Entries error notification in business central

editSubscribe (1) ShareShare
ReportReport
Posted on by 44

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

Categories:
Attachments
  • 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 2,984 Super User 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

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,130 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,689 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans