Trapping of dialogs and error messages

ottobe
Member Posts: 67
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?
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
-
Which error do you have?
It is always better to try to avoid errors in automation procedures.0 -
ottobe wrote:Even better: is it possible to trap the error and let the code decide what action to take?
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.RUN THEN BEGIN // your code for success END ELSE BEGIN // an error occurred inside MyCodeunit // your code for failure END;
If MyCodeunit errors out, it returns FALSE and you can write some code to handle that.
HTH0 -
Hi
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.0 -
ottobe wrote: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.blnOK := CONFIRM('want to continue?'); IF blnOK = TRUE THEN BEGIN // run some code END ELSE BEGIN // run some other code END;
If you want Navision to only run this if there is a user to click the message, you do the following:IF GUIALLOWED THEN blnOK := CONFIRM('want to continue?') ELSE blnOK := TRUE; //or whatever else you want to program IF blnOK = TRUE THEN BEGIN // run some code END ELSE BEGIN // run some other code END;
That's the simplest way that I can explain it.0 -
if you use DenSter's code, no error will be raised - false will be returned instead.
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.)0 -
Hi
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?0 -
it is code which posted user DenSter... (sorry - DenSter's code) 8)0
-
Eh..Sorry about that, DenSter.
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?0 -
Yeah, i have a comment ..
Good luck !
I think you need that writing this kind of automation servers ..
hope you now something about API programmingIn a world without Borders or Fences, who needs Windows and Gates?0 -
Maybe it isn't even possible what you want, because an automation server runs in the same proces as navision. This means that when a message pops up it will prevent your code from running to detect this same popup window.
Though i'm not sure a message will block your code, i'm affraid it will.In a world without Borders or Fences, who needs Windows and Gates?0 -
ottobe wrote:Eh..Sorry about that, DenSter.
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 luck0 -
By the way, you dont have to rewrite all Navision code, just the code that generates unwanted errors. You could also write the error message into a global text variable and get that from the errored out codeunit after it errored out.0
-
Before you call the codeunit to post check the fields for errors. IF you find bad data mark the record and move to the next record. I do this and it works fine.0
-
Hi,
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.
-A0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions