Hello.
I have some problem.
I connecting with Navision using sockets and I run some codeunit, which insert some data. If this codeunit cause an error i want to catch this error im my application. How I can get this error in nav?
Is there some function like GetLastError or something like this?
This error can't be shown in navision. How i can do this ?
I know how send it to/from navision.
Thanks
0
Comments
http://www.mibuso.com/forum/viewtopic.php?t=2343&highlight=catch+error
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
This is shame that in product like Navision there isn't a possibility to catch an error...
So if you do this: Your code will execute without aborting anything, even though MyCodeunit raises an error. The trick becomes how you want to catch the actual error. I've done something like this:
In one codeunit (called MyCodeunit): You also need a function to get the value of MyText:
Then you can call this codeunit from another codeunit inside an IF statement: And this will run fine without errors, even if MyCodeunit errors out.
You can get pretty fancy with this, just play around with it. The real pity is that if a record variable causes an error, Navision destroys it, so you can't catch the value straight from the record variable, you need to anticipate the error. Let me know if you need more help on this.
RIS Plus, LLC
I insert into navision Sales Headers and Sales Line from other application and I can't evaluate every field! There is to much possible errors.
There should be a function GetLastError. Micro$oft probably intentionally don't implemented it
See ya.
Remember that Microsoft did not create this product, Navision did. When they did, they put the emphasis on the functionality (creating a great ERP system) instead of cool development features. Of course we can debate whether error catching is a cool feature or a necessity, but the quality of the IDE was not the number 1 priority.
RIS Plus, LLC
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Peter
Yeah!! This is great, but it cause another problem
I can catch error message in TimerError trigger, but this error is first display in Navision. I know, I can use:
IF Table.Insert THEN...
but in this case TimerError doesn't catch this message!
What can I do ?
I want catch message only in TimeError and don't show it in Navision...
I have only used this with NAS where there is no GUI and so this is not an issue. I don't know if there is a way to suppress the error message in Navision, but I would guess that there is not.
- error
- message
- runmodal
- confirm
too bad; this does not work for a dialog screen.
Then you can automate a button click to remove the message.
Hope i will have some time to work on this, it shouldn't be that difficult if youre familiar with API programming.
EnumWinProc runs through all Window-Handles and will be fired by a Timer-Component every 10 seconds.
First you must get your own Process ID ... because C/Front is embedded as an OCX in my Application the C/Front message has the same PID as my Application.
The WindowClassName of Windows created by Navision is always #32770, the hell knows why
The Window Text of the C/Front Messages is always an empty String, so after checking the PID, the WindowClass and the Window Text i am sure that the current handle is the C/Front Message Window Handle.
Then I try to get the handle of the Text Control inside the Message Box. I tested it with the Program WinspectorSpy and the Label ID was always $FFFF.
At least you must send a Get-Message to the Window to get the Label's text. After that I send a Close-Event to close the Message Window and kill the line breaks in the Message Text.
I will try to use this system with automation and not C/Front, but i think the principles will be the same.
Maybe then we could create a C/AL error procedure which fires instead of a message popping up.
I used Spy++ to look up these parameters, but there is no way to distinguish a message from an error is there?
anyway many thanks O:)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I used jreynolds way. It's great and it's work.
I can catch all errors and show it in my application. I must change some chars to my encoding but it is easy
Thanks again.
I have try this procedure, but the Errore message PopUp, and the Trigger TimerError don't show the message.
Why???
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
With the procedure of "pduck", I succeed to close the window of PopUP, but the Crach of the Application (Report,CodeUnit,...,..) already has happened.
Do Not exist the way to capture the errors, and manage all from program and to manage all from program.
Visual Basic Version of "pduck" Procedute
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
"on error resume next"
Into C/AL. Seems impossible to me. I don't think you want this kind of behavior in a database program.
The error sink however is possible if you extend your code and add an event and rais the event when the error is catched.