Hi
I am trying to design a C/AL procedure for automating posting of several lines. The problem is that if there is an error on one line Navison produces an errormessage which nobody can confirm. Is it poosible to disable dialoges that need user intervention?
Even better: is it possible to trap the error and let the code decide what action to take?
0
Comments
It is always better to try to avoid errors in automation procedures.
There is no such thing in Navision as an error object, so no it is not possible to actually trap it. One way you could go however is to call a codeunit inside an IF statement. If MyCodeunit errors out, it returns FALSE and you can write some code to handle that.
HTH
RIS Plus, LLC
The IF MyCodeunit.RUN might work for some cases, but not all. Thanks.
To exemplify:
I want to post lines using the Navision standard posting codeunits. My posting process is trigged automatically-no user is around. If some data is erronous on one line, Navision displays a dialog concerning bad data in a record. The problem is- the execution stops waiting for the user to click OK.
Instead I would like to mark the error as errounous and continue to next line. And I would prefer not to modify standard Navision codeunits.
The same applies to inbuilt Navision field validation in other circumstances.
RIS Plus, LLC
But htere is another solution (workaround) - if you user 'Navision Timer 1.0'.Timer automation, and use it to run some code, on this automation is TimerError trigger which is raised on error and have parameter ErrorString which hold Navision error text!
When you combine DenSter's code and Navision Timer automation, you can run posting without raising error and have tool to save error text...
I use this for scheduled adjustment with error log (if some error is found, error is logged into some table etc.)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Yes I have noticed that the TimerError picks up all Errormessages when the timer is enabled, and I have actually used that as an error trap once.
Does anybody have more experience with it?
By the way. What is DenSter code?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The problem with that is that I have to rewrite all Stndard Navision Code.
I was thinking of an other solution:
Write e.g. an automation server that invokes Windows (the OS) to check if a New window pops up (with some ID check).
- From my control CU: Enable it before running a specific Code unit.
- If a dialog pops up- kill it.
- Report back to Navision, my Control CU
Any comments?
Good luck !
I think you need that writing this kind of automation servers ..
hope you now something about API programming
Though i'm not sure a message will block your code, i'm affraid it will.
Good luck
RIS Plus, LLC
RIS Plus, LLC
So do you guys propose removing all of the TESTFIELDS in all of the codeunits that you are trying to automate?
Or write another codeunit that determines whether or not the testfield will fail before you call the codeunit?
That would be my only worry, a testfield will give a dialog box if it fails thus stopping your posting routine.
-A