Error handling by NAS

einsTeIn.NET
Member Posts: 1,050
Hello,
I use NAV 4.03. I installed a NAS as service. It starts a singleinstance codeunit with NAVTimer. When the timer event is fired, the following code is executed:
I use NAV 4.03. I installed a NAS as service. It starts a singleinstance codeunit with NAVTimer. When the timer event is fired, the following code is executed:
... REPORT.RUNMODAL("Object No.",FALSE,FALSE);The report does execute the following for every Sales Header within a certain filter:
... IF Codeunit1.RUN(SalesHeader) THEN BEGIN ... IF SalesLine.FINDSET THEN REPEAT IF Codeunit2.RUN(SalesLine) THEN; UNTIL SalesLine.NEXT = 0;I thought this IF XXX.RUN(Rec) THEN construction makes sure that no error can break the loop. I mean if there is an error with a certain Sales Line it should go to the next Sales Line and try to execute the codeunit with this next Sales Line as parameter. But it always ends up at the singleinstance codeunit. Even if there is an error in the first codeunit for Sales Header. What am I doing wrong?
"Money is likewise the greatest chance and the greatest scourge of mankind."
0
Answers
-
It seems that the NTimer has own error handling (there is OnError trigger) and it is ignoring the "silent" error which is raised when using "if codeunit.run then" construction.0
-
What does that mean? I know about this OnError trigger of the timer component. Do you mean this "silent" error workaround does not work for timer triggered solutions? Or do you mean it does not work if there is any code within the OnError trigger?"Money is likewise the greatest chance and the greatest scourge of mankind."0
-
I mean it seems that it not work when the process was started from OnTimer event.0
-
Okay! So, any suggestions how to change the code to get rid of that problem? ](*,)"Money is likewise the greatest chance and the greatest scourge of mankind."0
-
Look into event log, which errors you see there, if it is only the error inside the codeunit which is expected or if there are other errors... just to be sure that the problem is not somewhere else...0
-
I have used the timer object ('Navision Timer 1.0'.Timer) several times in a single instance code unit run by nas.
In the Timer-Event trigger I just put the call to the worker codeunit.
In the TimerError-Event Trigger I put code like this// without enabling it again the timer event does not fire anymore myTimer.Interval := mySetup."My Process Inbound Monitor Interv." * 1000; myTimer.Enabled(TRUE); // some error handling here
In these scenarios I have never used "if codeunit.run" construct.
Hope this helps
Thomas0 -
There are no error messages within the event log. Should NAS write into the event log even if you use IF codeunit.RUN THEN construction?"Money is likewise the greatest chance and the greatest scourge of mankind."0
-
I've used "IF codeunit.RUN THEN" with the Navision timer many times. It works just fine. I will follow the FALSE return with a GETLASTERROR call in order to log the error to a table.There are no bugs - only undocumented features.0
-
bbrown wrote:I've used "IF codeunit.RUN THEN" with the Navision timer many times. It works just fine. I will follow the FALSE return with a GETLASTERROR call in order to log the error to a table.
Yes but only if you are on NAV 5.00... ;-)0 -
einsTeIn.NET wrote:There are no error messages within the event log. Should NAS write into the event log even if you use IF codeunit.RUN THEN construction?
No, it shouldn't, but that there is no error in the event log is good thing and bad thing. Good that we know that there is no another uncatched error, bad is that it will not help... :-k0 -
kine wrote:bbrown wrote:I've used "IF codeunit.RUN THEN" with the Navision timer many times. It works just fine. I will follow the FALSE return with a GETLASTERROR call in order to log the error to a table.
Yes but only if you are on NAV 5.00... ;-)
That's why I've done some technical upgrades. I've got this approach running with database versions back to 3.60, but with 5.x (or higher) clients.There are no bugs - only undocumented features.0 -
bbrown wrote:I've used "IF codeunit.RUN THEN" with the Navision timer many times. It works just fine. I will follow the FALSE return with a GETLASTERROR call in order to log the error to a table."Money is likewise the greatest chance and the greatest scourge of mankind."0
-
If you implement your error handling in the TimerErrorEvent-Trigger you can use the ErrorText property there, so you don't have to use the GetLastError of 5.x Nav.
Thomas0 -
The OnError event of the timer is not fired each time in a loop with "IF codeunit.RUN" contruction. But that's not my problem. The execution of the report is terminated. I want the report to go to the next record and run the codeunits with the new record.
I even tried to execute the report's functionality through a new codeunit. Same error.SalesHeader.SETCURRENTKEY(...); SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Order); ... //some other filters SalesHeader.SETFILTER("Order Date",'..%1',TODAY); Codeunit1.SetHideDialog(TRUE); IF SalesHeader.FINDSET THEN REPEAT IF Customer.GET("Sell-to Customer No.") THEN IF NOT Customer.Blocked THEN BEGIN //Codeunit1.RUN(SalesHeader); IF Codeunit1.RUN(SalesHeader) THEN BEGIN HandleLines; COMMIT; END; END; UNTIL SalesHeader.NEXT = 0; // Function HandleLines SalesLine.SETRANGE("Document Type",SalesHeader."Document Type"); SalesLine.SETRANGE("Document No.",SalesHeader."No."); IF SalesLine.FINDSET THEN REPEAT IF Codeunit2.RUN(SalesLine) THEN; //Codeunit2.RUN(SalesLine) UNTIL SalesLine.NEXT = 0;
And I commented out all code in OnRun of codeunit1. Still the same error."Money is likewise the greatest chance and the greatest scourge of mankind."0 -
Sorry guys, it was my fault. #-o There was a LOCKTABLE one codeunit above. I did not create that codeunit, so I did not pay enough attention to it.
Back to topic: Unfortunately there is no way to get the real last error in a "IF codeunit.RUN" contruction until 5.00 and GETLASTERROR. :-k"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
Is there a reason that a technical upgrade (newer clients) can't be done here?There are no bugs - only undocumented features.0
-
No, there is no real reason. The customer only wants to spare the effort. I will suggest him to do a technical upgrade. Otherwise he has to live with this "feature"."Money is likewise the greatest chance and the greatest scourge of mankind."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