We all know (and if you don't search the forum) that the only way to catch errors in Navision is the
If codeunitA.RUN then
structure. We also know that you can programatically call codeunits with the this structure
Codeunit.run( Codeunit's Object Number )
However, its less known that when using the latter structure anywhere in the cal stack, it will cause errors from the previous structure to NOT be caught.
To put it another way, if you use the if codeunit.run() structure anywhere in the call stack, you can't catch any errors. Very important when writing code that use the Job Scheduler.
Comments
It is not true that this is the only way to catch errors with codeunits. There is really no difference between calling the method of a codeunit variable, or just writing If you call the latter example the same way using the IF structure, you can catch the errors in the very same way.
There is only one advantage to using a codeunit variable: you can initialize the codeunit by calling user defined functions that set global variables, and you can obtain the result of the transaction by calling user defined functions that return status, or whatever that is stored in global vatriables.
The difference between calling the RUN procedure (any way) with the IF structure, is that Navision handles the erros by aborting - and rolling back - the transaction when you don't use the IF structure. If this is not wat you want, or you need custom error handling, you can use the IF structure. It just works like the GET from the RECORD variable type.
But i needed the information about the error.
I needed the whole error message.
With other words, the message that is display if there where an userinterface. But nas doesnt have Guid.
So i've changed my code to folloing:
loop through Seduling setup records
With this, i can see, why the job is not running.
I havn't tried that yet, but I sure will sometime in the future. I've been writing custom error handling code that sets an error message to be retrieved by a custom function. It sure is a lot of work. You end up with more error catching code than anything else! Your solution will save me a lot of time!