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)
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.
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
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.
Answers
Or schedule the job yourself from the run codeunit and set a error codeunit that sends the mail. (2017 only)
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)
Send mail;
https://msdn.microsoft.com/en-us/dynamics-nav/createtask-function
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
This makes sense,
is there anyway to achieve this in NAV witout running in a job queue
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
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?
Hint... Look at "Mail Item" table. It does it all...
Check this out
https://rockwithnav.wordpress.com/2016/10/03/configure-sql-email/
https://rockwithnav.wordpress.com/2016/10/03/sql-email-query/
Configure this for Job Queue failure.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
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
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03