SBX - Search With Button

SBX - Forum Post Title

Is it possible to capture list of errors, in a continued way without terminating the process, if my code encounters error ???

Microsoft Dynamics NAV Forum

NAV Techie asked a question on 11 Jul 2018 2:27 AM

Question Status

Unanswered

Hello Everyone,

I have created a code unit which copies one table data into another table(record), I have given it condition as if it encounters any error it captures using "GETLASTERRORTEXT"  but the problem is it terminates the entire copying process if any field hits error ex. if the string length or data type differs., Is it possible to continue the copying process even after it hits an error?I want a list of errors in my error log table. 

Reply
Hannes Holst responded on 11 Jul 2018 5:41 AM
My Badges

Hi,

You can capture errors with the return value of Codeunit.RUN:

https://docs.microsoft.com/en-us/dynamics-nav/codeunit.run-function--codeunit-

If you include the return value and an error occurs, then the calling C/AL code continues to run. This means that you must handle any errors.

You need a function which loops through each field of your source record. The copy-process itself must take place in the 2nd codeunit (which you call with "bolSuccess := Codeunit.RUN".

Reply

SBX - Two Col Forum

SBX - Migrated JS