Take a look at the codeunit 397 Mail. You can use a function NewMessage in this codeunit to sent email using your standard email client.
The only problem is that you will ahve to check manually the condition taht generates error and send email before this condition is checked in the standard code and error is raised.
Something is wrong with my language today #-o so let me know if it helps
basically when a Navision process dies, its too late to send a message that it died.
We had a client that imported invoices in from a Unix system to Navision, this was done about every hour or so. But often UNIX and windows would fight over the file, and the Navision dataport would die. It just needed to be restarted and all was fine. The dataport it self ran from a loop that looked to see if the file was there, if so imported it, and then moved the file somewhere else.
What we did in the end is ran two Navision sessions on the machine, then between each import we commited a record to a new table, with status, so if the status was not updated to complete, the second task would wait 5 minutes, and then send an email to a provider that could redirect this to an SMS. That way the operator got a message on his cell phone when the process stopped.
It worked great for about 6 months, but then when Navision released 2.00 they fixed up both GETLATESTVERSION and the way Navision moved files, so it ran smoothly and we didn't need the function any more.
Anyway its a lot of work, but it is possible. Oh and now there is OnTimmer in forms, which makes it even easier.
I found a little difficult to found mannualy the error and send an e-mail just before the condition is checked (?) Is it possible? so I have to checked all the possible errors, no way if the Report for example just hang up...
let me know if I understand what you said me...
Ok, let me just rephrase it.
Lets say you have following code
IF Record.Field1 = 'abc' THEN
ERROR("Field cannot be 'abc'!")
When the program hits the ERROR line there is no way of catching the error - program just gives a runtime error and stops. Basically NOTHING can be done after ERROR command.
One of the solutions is to check the condition that can possibly generate error before processing ERROR line.
So code can look like this:
IF Record.Field1 = 'abc' THEN BEGIN
IF Mail.NewMessage(...) THEN; //Thius line will send your error email
ERROR("Field cannot be 'abc'!");
END;
I know it is a lot of work to check every possible scenario to prevent generation of errors before this email can be sent but I do not think tehre is an easier way.
In version 5 there wiill be a function to return the last error, so you can email it, but we havce what we have.
If you will take a look at the job scheduler and the way taht those error lines get there you will see that it is all programmed in code to populate the line of the Job Scheduler, so it is not done automatically.
Another idea. You can try to send an email every time this line in Job Scheduler is being populated.
IF your report is hanging you will have to find a reason why it is doing that and correct it.
If you want to check the job sheduler, you need to build a watchdog. In electronics this is mostly build at hardware level. It can be found back in PLC's, ...
I build it in a software way to check the sheduler. I checked the sheduler jobs and I found that the longest job toke several hours, but that was only during the night. During the day it was only 3 minutes. I modified the job sheduler that after every job, a date and time field is filled on the job sheduler setup (last date and time of execution). I made a small form that is automatically opened when you open the navision application (but only for a certain user). In that form is a timer build in. Every minute a check there to see if the latest execution time of the sheduler is longer then 5 minutes, if so an alarm will sound to inform that the sheduler did stop running. Because the user never logs in during the night, i don't have problem with the long runs of the night.
Don't use this watchdog routine on the same pc as the sheduler is running, if so you will get no messages if for exemple the sheduler isn't running no more.
This principe of watchdog is well known to and used by many hard- and software builders.
If you want to check the job sheduler, you need to build a watchdog. In electronics this is mostly build at hardware level. It can be found back in PLC's, ...
](*,)
Well if Matias didn't like it when I suggested it, you are probably wasting time repeating it. #-o
Interesting then that we both make the same suggestion. I would think that's a good indication that its the best way to go. Maybe Matias will give it a second thought now.
By the way, we ran both tasks on the same machine, and never had any problems. I wrote this back in Ver 1.3 before OnTimmer exists, so it was pretty unstable in the begining, but once it was working, I never had a problem running both Navision sessions on the same machine. It was running 24/7 for years.
Sorry for the delay, I was two days off. One question, I am interesting on doing some SQL Store Procedure and check in the table Job Sheduler Manager or Job Scheduler Log, what do you think? What would be a good way to check the errors???
Thanks to all!!!
Comments
The only problem is that you will ahve to check manually the condition taht generates error and send email before this condition is checked in the standard code and error is raised.
Something is wrong with my language today #-o so let me know if it helps
Oleg
I will check that codeunit right now
thanks
basically when a Navision process dies, its too late to send a message that it died.
We had a client that imported invoices in from a Unix system to Navision, this was done about every hour or so. But often UNIX and windows would fight over the file, and the Navision dataport would die. It just needed to be restarted and all was fine. The dataport it self ran from a loop that looked to see if the file was there, if so imported it, and then moved the file somewhere else.
What we did in the end is ran two Navision sessions on the machine, then between each import we commited a record to a new table, with status, so if the status was not updated to complete, the second task would wait 5 minutes, and then send an email to a provider that could redirect this to an SMS. That way the operator got a message on his cell phone when the process stopped.
It worked great for about 6 months, but then when Navision released 2.00 they fixed up both GETLATESTVERSION and the way Navision moved files, so it ran smoothly and we didn't need the function any more.
Anyway its a lot of work, but it is possible. Oh and now there is OnTimmer in forms, which makes it even easier.
let me know if I understand what you said me...
Thanks again!
Lets say you have following code When the program hits the ERROR line there is no way of catching the error - program just gives a runtime error and stops. Basically NOTHING can be done after ERROR command.
One of the solutions is to check the condition that can possibly generate error before processing ERROR line.
So code can look like this:
I know it is a lot of work to check every possible scenario to prevent generation of errors before this email can be sent but I do not think tehre is an easier way.
In version 5 there wiill be a function to return the last error, so you can email it, but we havce what we have.
If you will take a look at the job scheduler and the way taht those error lines get there you will see that it is all programmed in code to populate the line of the Job Scheduler, so it is not done automatically.
Another idea. You can try to send an email every time this line in Job Scheduler is being populated.
IF your report is hanging you will have to find a reason why it is doing that and correct it.
Oleg
I build it in a software way to check the sheduler. I checked the sheduler jobs and I found that the longest job toke several hours, but that was only during the night. During the day it was only 3 minutes. I modified the job sheduler that after every job, a date and time field is filled on the job sheduler setup (last date and time of execution). I made a small form that is automatically opened when you open the navision application (but only for a certain user). In that form is a timer build in. Every minute a check there to see if the latest execution time of the sheduler is longer then 5 minutes, if so an alarm will sound to inform that the sheduler did stop running. Because the user never logs in during the night, i don't have problem with the long runs of the night.
Don't use this watchdog routine on the same pc as the sheduler is running, if so you will get no messages if for exemple the sheduler isn't running no more.
This principe of watchdog is well known to and used by many hard- and software builders.
Consultant-Developper
http://www.CreaChain.com
Well if Matias didn't like it when I suggested it, you are probably wasting time repeating it. #-o
I did see the question, and I was so quick to answer about the watchdog functionality that I didn't read well the other proposed solutions.
Consultant-Developper
http://www.CreaChain.com
By the way, we ran both tasks on the same machine, and never had any problems. I wrote this back in Ver 1.3 before OnTimmer exists, so it was pretty unstable in the begining, but once it was working, I never had a problem running both Navision sessions on the same machine. It was running 24/7 for years.
Nice!
Thanks to all!!!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n