GETLASTERRORTEXT - How to use - How to set up the system

Steffen_Brodowski
Member Posts: 20
Hello!
Does anybody know, how the new function "GETLASTERRORTEXT" in Nav 5.0 is to handle?
Onlinehelp is showing as follows:
"Use this function to return the text that was contained in the last error message displayed by the system."
Comments of the helping:
"You can set up Microsoft Dynamics NAV so that it keeps running even if a runttime error occurs. You can use this function to find out whether or not an error has occurred and to see the actual text in the last error message that was generated."
So my question is: How to set up Navi, so there occurs no runtime error when an automationserver occurs an exeption?
Because its like an error in navi, witch will close forms, if it occurs at the OnOpenForm trigger for example but the begin of the error message is: "This message is for C/Side developpers...."
Greetings
Steffen Brodowski
Does anybody know, how the new function "GETLASTERRORTEXT" in Nav 5.0 is to handle?
Onlinehelp is showing as follows:
"Use this function to return the text that was contained in the last error message displayed by the system."
Comments of the helping:
"You can set up Microsoft Dynamics NAV so that it keeps running even if a runttime error occurs. You can use this function to find out whether or not an error has occurred and to see the actual text in the last error message that was generated."
So my question is: How to set up Navi, so there occurs no runtime error when an automationserver occurs an exeption?
Because its like an error in navi, witch will close forms, if it occurs at the OnOpenForm trigger for example but the begin of the error message is: "This message is for C/Side developpers...."
Greetings
Steffen Brodowski
0
Comments
-
Hi
From Batch post Salesordre:
CLEARLASTERRORTXT;
IF SalesPost.RUN("Sales Header") THEN BEGIN
CounterOK := CounterOK + 1;
ErrorTxtVar := 'Not a problem';
IF MARKEDONLY THEN
MARK(FALSE);
END
ELSE
ErrorTxtVar := LASTERRORTXT; // Only LAST !!!!!!!!!!
If Salespost.RUN fail the error will not display or stop the program,
and you can not display the error.
You can eg. make a list of errors on the Invoices that fail posting.
This is now possibel with GETLASTERROR.
BR Per0 -
It does not seem to work... If I have a codeunit called Child which has one line of code - ERROR('Something'); and another codeunit called Parent which says:
CLEAR(Child); IF NOT Child.RUN THEN BEGIN IF GETLASTERRORTEXT<>'' THEN MESSAGE('First error returned from child: '+ GETLASTERRORTEXT); CLEARLASTERROR; END; CLEAR(Child); IF NOT Child.RUN THEN BEGIN IF GETLASTERRORTEXT<>'' THEN MESSAGE('Second error returned from child: '+ GETLASTERRORTEXT); CLEARLASTERROR; END;
then it does not work properly: it only displays the second one. Any ideas?
Also I cannot find that example code in Batch Post Sales Orders but the reason could be that the version number says NAVW15.00,NAVGB4.00 - which means the UK localisation might be a mixture of NAV5 and NAV4.
However, I found some example code in Codeunit 5304 Outlook Synch. Outlook Mgt. :IF NOT OSynchProcessLine.RUN THEN BEGIN IF GETLASTERRORTEXT <> '' THEN WriteErrorLog( OSynchUserSetup."User ID", EntityRecID, 'Error', SynchEntityCode, GETLASTERRORTEXT, ErrorLogXMLWriter, Container); CLEARLASTERROR; ErrorConflictBuffer.RESET; ErrorConflictBuffer.INIT; ErrorConflictBuffer."User ID" := UserID; ErrorConflictBuffer."Record ID" := EntityRecID; ErrorConflictBuffer."Search Record ID" := FORMAT(EntityRecID); IF ErrorConflictBuffer.INSERT THEN; END;
It's exactly the same as I'm trying to do above - if we assume it works, any ideas why the above one doesn't?0 -
Hey Miklos,
try it with the CONFIRM instead of the MESSAGE Dialog. MESSAGE will only execute at the end of a codeunit. (Don't ask me why) :?
This code will work:
CLEAR(child);
IF NOT child.RUN THEN BEGIN
IF GETLASTERRORTEXT<>''
THEN IF CONFIRM('First error returned from child: %1',TRUE, GETLASTERRORTEXT) THEN;
CLEARLASTERROR;
END;
CLEAR(child);
IF NOT child.RUN THEN BEGIN
IF GETLASTERRORTEXT<>''
THEN IF Confirm('Second error returned from child: %1', TRUE, GETLASTERRORTEXT) THEN;
CLEARLASTERROR;
END;
Hope this Helps,
KYDutchieFostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.0 -
try it with the CONFIRM instead of the MESSAGE Dialog. MESSAGE will only execute at the end of a codeunit. (Don't ask me why)
To not pause the running transaction and prevent long lock waiting times. It will be BIG disaster if Message stop transaction processing like CONFIRM... :whistle:
(it was big problem in older versions where MESSAGE in some situations blocked the transaction... imagine process - e.g. batch posting - which shows message "Posting done" at the end of 30 minutes of running, when user is away for a break, and all others are waiting till he return and click the OK button...)0 -
Thanks, it works. Interesting. In other situations, like when I'm messaging out some sort of debugging value when posting an order of five lines, all five messages promptly come up and the end of the transaction. In this case actually it has nothing to do with GETLASTERRORTEXT - even without it only the second MESSAGE is shown. i.e.
IF NOT Child.RUN THEN BEGIN MESSAGE('First error returned from child: ') ; END; IF NOT Child.RUN THEN BEGIN MESSAGE('second error returned from child: ') ; END;
This is really interesting and I think the reason might be that there must be some sort of MESSAGE cache and when we run the codeunit the second time it's getting cleared up.
Anyway, it means that the important thing, the GETLASTERRORTEXT works this way. What I'm doing is that I'm loading and posting Output Journals from an external shop floor application via appserver. And if the journal posting goes tits up, I'll skip that one and send the last error text to the internal IT via e-mail. That's seriously cool that this is now possible - that almost looks like a real server-side application, not just a GUIless client0 -
If you try with Dialog object, you could have a dialog ever open and value of Text Cont linked on dialog ever active.
DIALOG.OPEN('Status: #1######################'); IF NOT Child.RUN THEN BEGIN DIALOG.UPDATE('First error returned from child: ') ; END; IF NOT Child.RUN THEN BEGIN DIALOG.UPDATE(1,'second error returned from child: ') ; END DIALOG.CLOSE;
And so on.....0 -
Miklos Hollender wrote:Thanks, it works. Interesting. In other situations, like when I'm messaging out some sort of debugging value when posting an order of five lines, all five messages promptly come up and the end of the transaction. In this case actually it has nothing to do with GETLASTERRORTEXT - even without it only the second MESSAGE is shown. i.e.
IF NOT Child.RUN THEN BEGIN MESSAGE('First error returned from child: ') ; END; IF NOT Child.RUN THEN BEGIN MESSAGE('second error returned from child: ') ; END;
This is really interesting and I think the reason might be that there must be some sort of MESSAGE cache and when we run the codeunit the second time it's getting cleared up.
Anyway, it means that the important thing, the GETLASTERRORTEXT works this way. What I'm doing is that I'm loading and posting Output Journals from an external shop floor application via appserver. And if the journal posting goes tits up, I'll skip that one and send the last error text to the internal IT via e-mail. That's seriously cool that this is now possible - that almost looks like a real server-side application, not just a GUIless client
Yes, there is Message stack which is displayed on end of the transaction to prevent locking (only Confirm will block the transaction). And clearing the stack is one "small" bug (or feature?).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