I have a code unit that insert data into a custom table. I Need to retreive and log all error occuring when Insert command fail. I Use a line taht looks like that :
IF NOT tmpRecord.INSERT THEN BEGIN
Is there any way to get the error message why the code-unit goes into this condition.
Answers
If you are on 5.0 you can use a construct like the following to catch and log the eventual error caused by not inserting the record:
Regards
but as far as I know if it goes in the IF condition it should have an error, right?
programmeur-analyste
Cabico Custom Cabinetry
Have you tried to modify your code to use this context?
And to have correct error, the error must be fired, it means the INSERT must be used without return value (without the IF), else there is no error thus no error message in the GETLASTERRORTEXT...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
programmeur-analyste
Cabico Custom Cabinetry
That's correct. Or use the current one and change the logic, but do not use "if not insert then...", just "record.insert;...".
Then call this codeunit with the construction "If codeunit.run() THEN..."
Where the code in the gWriteCodeUnit looks like :
Maybe it's not pretty but it work just fine !
programmeur-analyste
Cabico Custom Cabinetry
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
programmeur-analyste
Cabico Custom Cabinetry
Open the codeunit in designer, press Shift+F4... TableNo...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thanks
programmeur-analyste
Cabico Custom Cabinetry