Discussion:
GETLASTERRORTEXT in NAV 4.0 SP3
(too old to reply)
Andy
2008-03-03 17:19:02 UTC
Permalink
Hello,

I used the function GETLASTERRORTEXT in version 5.0.

Now I should use the same function in a db ver 4.00 sp 3 but I don't have
this function.

I need it to log if a codeunit goes wrong, returns false:


Following is the code running on 5.0

IF NOT CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post Batch",gRecItemJournalLine)
THEN BEGIN
retValue := FALSE;
ErrorLogMgt.SetInterruptingSeverity := 0;
ErrorLogMgt.LogError(TaskCode,
TaskID,
'BATCH_ERROR',
COPYSTR(GETLASTERRORTEXT,1,250)
,(GETLASTERRORTEXT,251,500)
,0);
CLEARLASTERROR;
END


How can I have same functionality in 4.0 sp3?

Thank you
f***@4bsoftware.biz
2008-03-04 08:38:31 UTC
Permalink
Hello,

you cannot use this function in NAV 4.03 :-(

Regards

Billy
PalleA
2008-03-04 08:39:11 UTC
Permalink
Post by Andy
Hello,
I used the function GETLASTERRORTEXT in version 5.0.
Now I should use the same function in a db ver 4.00 sp 3 but I don't have
this function.
Following is the code running on 5.0
IF NOT CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post Batch",gRecItemJournalLine)
THEN BEGIN
           retValue := FALSE;
           ErrorLogMgt.SetInterruptingSeverity := 0;
           ErrorLogMgt.LogError(TaskCode,
          TaskID,
          'BATCH_ERROR',
           COPYSTR(GETLASTERRORTEXT,1,250)
          ,(GETLASTERRORTEXT,251,500)
         ,0);
          CLEARLASTERROR;
END
How can I have same functionality in 4.0 sp3?
Thank you
As the command only exists in 5.0 then it is not possible to get the
Errormessage. The only way is to check everything yourself before you
choose to run the codeunit.

As an alternative plan - you could choose to runtime upgrade to 5.0
(and stick to the 4.0 objects) and by that get the command available.

PalleA
Daniel Rimmelzwaan
2008-03-06 02:30:39 UTC
Permalink
That is a new C/AL keyword in 5.0 so it will never work in previous
versions. You CAN however catch error messages, but you have to program it
all. Declare the codeunit as a global variable, and if the codeunit causes
an error, all global variables inside the codeunit will still be alive.
So.... you can create little functions in that codeunit to retrieve the
values. This way, you can keeo track of what you are doing inside the
codeunit, and retrieve that from the codeunit after it returns false. The
only thing it does NOT know is the record variable that causes the error,
which gets destroyed when it errors out.

Don't know if I am making sense here, so let us know if you need more help.
--
Daniel Rimmelzwaan
MVP Dynamics NAV
www.risplus.com
Post by Andy
Hello,
I used the function GETLASTERRORTEXT in version 5.0.
Now I should use the same function in a db ver 4.00 sp 3 but I don't have
this function.
Following is the code running on 5.0
IF NOT CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post Batch",gRecItemJournalLine)
THEN BEGIN
retValue := FALSE;
ErrorLogMgt.SetInterruptingSeverity := 0;
ErrorLogMgt.LogError(TaskCode,
TaskID,
'BATCH_ERROR',
COPYSTR(GETLASTERRORTEXT,1,250)
,(GETLASTERRORTEXT,251,500)
,0);
CLEARLASTERROR;
END
How can I have same functionality in 4.0 sp3?
Thank you
Loading...