Trapping Navision Error

bhuber
Member Posts: 78
On an insert or modify error I would like to trap the Navision error message. Is this possible?
0
Comments
-
Sure, use the return-value to check if there was an error:
IF NOT(rec.INSERT) THEN;
IF NOT(rec.MODIFY) THEN;No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Beware of the fact that IF NOT INSERT is not recomended when using SQL option.
USE
IF GET(Keyfields) then
error
instead of
IF NOT INSERT THEN
Luc, do you have this document? Maybe you can put it on the download.
The document is called Tuning Navision for better performance and is from Microsoft I believe.
Let me know if you want it.0 -
I am running a codeunit and attempting to insert a record. There are various reasons why the insert may fail. I would like to trap the specific Navision error message and set a variable equal to it. Not sure how I can do it with your code? For example, say I wanted to create an error log table with one of the fields specifically storing the Navision Error Message.0
-
Mark Brummel wrote:Luc, do you have this document? Maybe you can put it on the download.
The document is called Tuning Navision for better performance and is from Microsoft I believe.
http://www.mibuso.com/dlinfo.asp?FileID=3560 -
-
Your code
IF GET(Keyfields) then
error
will test if Isert will work and returns an error, but how can I trap the specific error message to a variable? It would appear that I need do something like this
Variable := IF GET(Keyfields) then error
and of course this doesn't work. Again I may be missing something.
Thanks for your help.0 -
I think it depends on what you are trying to achieve.
There is no thing in Navision that supresses the error message and put it in a log file.
So you need to make some checks yourself.
The difficulty depends on what you are trying to insert. If you want to make a sales order, there are tons of things that can go wrong.
If you want to insert a contact, or even a posting group, things get easier.
What is it exactly you want to import and what errors do you want to prevent from happening?0 -
The short answer is that no you cannot trap a Navision error. There is no error object in the Navision IDE. You can program defensively and trap errors before they occur and then analyze a variable that you use to keep the error description, but that would require extensive programming.
But.... if you just do MyRec.INSERT and that fails for whatever reason, you will not be able to figure that one out in C/AL code. It is not possible to catch the error description that you see in the messagebox, unfortunately.0 -
I was afraid you would tell me it was not possible. I could not see how to do it. So what I am going to do is attempt to test all possible errors before the insert.
Thanks0 -
Well you could tell us exactly what you are thinking of and you'd be surprised at how many different ways you could do it. We've all been where you are now, and there may be an easy way to do what you want to do.0
-
**Might as well link these**
Trapping of dialogs and error messages
http://www.mibuso.com/forum/viewtopic.php?t=34320 -
Here is what I am doing. I am using a third party product to access Navision through the application server to insert modify etc. What I was trying to do was let Navision tell me why it could not insert or modify and then send this info back to the external source. However, since it doesn't look like I can do this, I will have to test for specific errors and then send back corresponding messages. This makes for more work and if I miss a possible error type then I have a problem.0
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