Skip to main content

Notifications

Small and medium business | Business Central, N...
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

  • 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,926 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,056 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans