Job queue failure email notification

FMCFMC Member Posts: 12
Hi,

I have NAV 2017 and want to create an email if a job in the job queue fails.

is there a workflow for this or what will be the best way to achieve this

Thanks

FC

Answers

  • JuhlJuhl Member Posts: 724
    You could start your codeunit from another codeunit and use the return value to determine if it was a success. Then send email from there.

    Or schedule the job yourself from the run codeunit and set a error codeunit that sends the mail. (2017 only)
    Follow me on my blog juhl.blog
  • FMCFMC Member Posts: 12
    thanks for the info,

    Please can you help advise what the actual code will be to aciveve this
    "schedule the job yourself from the run codeunit and set a error codeunit that sends the mail"

    how can you start a codeunit from another code unit (not something I have done before)
  • JuhlJuhl Member Posts: 724
    Follow me on my blog juhl.blog
  • FMCFMC Member Posts: 12
    thanks, I will give this a go
  • RockWithNAVRockWithNAV Member Posts: 1,139
    Dont use this codeunit as another job queue because again there may a probability that this Job may stop. I too faced a situation like this and I wrote a SQL job for this.
  • FMCFMC Member Posts: 12
    Dont use this codeunit as another job queue because again there may a probability that this Job may stop. I too faced a situation like this and I wrote a SQL job for this.

    This makes sense,

    is there anyway to achieve this in NAV witout running in a job queue
  • JuhlJuhl Member Posts: 724
    Have the users watch the job que.
    I usually make a pagepart in the role center for this.

    Use built in NAV features not sql.

    Everything can fail, even your car breaks down, does that stop you from driving it?
    Follow me on my blog juhl.blog
  • FMCFMC Member Posts: 12
    Juhl wrote: »
    Have the users watch the job que.
    I usually make a pagepart in the role center for this.

    Use built in NAV features not sql.

    Everything can fail, even your car breaks down, does that stop you from driving it?

    I will try your way, are you able to give me a little more info on how to create this
  • JuhlJuhl Member Posts: 724
    Create what ?
    Follow me on my blog juhl.blog
  • FMCFMC Member Posts: 12
    Juhl wrote: »
    Create what ?

    once I create a codeunit with this code

    IF NOT Codeunit.RUN THEN
    Send mail;

    do I need to define the send mail parameter/variable and a template to use?

  • JuhlJuhl Member Posts: 724
    Yes, the mailpart is up to you, i just wrote it for understanding. There are many ways to send mail.

    Hint... Look at "Mail Item" table. It does it all...
    Follow me on my blog juhl.blog
  • FMCFMC Member Posts: 12
    thank you, I will give this a try
  • FMCFMC Member Posts: 12
    does anyone have any examples of how to achieve Job queue failure email notification
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Hi,

    Did you try to create a codeunit/report which would look into Job Queue Entry and/or another Job Queue Log Entry log and send a notification or email when a Job Queue Entry with Status=Error is found? You would need some logic + modification of the Job Queue Entry table, or a custom table, to make sure you don't report the same error twice.

    Once you have this report/codeunit working you could set it up as a separate job run every few minutes.


    Also, if you are on NAV 2017, you could use Intergration events, create a subscriber function subscribing to Job Queue Entry table OnAfterModify event and send an email if a modification is made and the Status is set to Error. This solution would have the advantage that you would not have to have another job running, which someone could put into Hold.

    Slawek


    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.