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
0
Comments
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 Per
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. :
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?
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,
KYDutchie
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...)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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
And so on.....
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?).
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.