Hello,
I am using native web service in NAV2009 [GB Dynamics NAV 6.0, no hotfixes].
I have the web method that contains only the code below that should basically just "log something" in the InMsg table no matter whether there was an error in CU 99500 or not:
IF CODEUNIT.RUN(99500) THEN ;
InMsg.INIT;
InMsg."Message ID" := 'test';
InMsg.INSERT;
If there is no error in CU 99500 then the record is created in InMsg table as expected.
However if there is an error in CU 99500 the rest of the code in the method is performed (as expected), but the whole transaction seems to be rolled back and there is no record in InMsg table once the WS call finishes. If the same method is called from classic client, the record is created as expected.
Could somebody please explain to me why is this happenning and how can I make this code working as expected?
Thanks ahead,
Igor
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
It seems like the AL Exception handler doesn't work - meaning that the exception in your codeunit.run causes the Web Service to fail.
I will investigate this and file a bug if that is the case.
Have you tried outcommenting your if codeunit.run statement and verified that you actually get a log entry then?
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I have tried to change the code to the following one but the result was the same:
IF the CU.RUN is commented out, the code works as expected - the record is inserted in NAV.
According to me this behaviour is a bug as:
1) Web Service returns without error and with correct return value (i.e. it has reached the end). Therefore I would expect the whole DB transaction to have been successful as well.
2) Just the whole DB transaction seems to have been aborted.
Regards,
Igor
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
As the error is handled, there should be an implicit COMMIT when the Web service operation exits.
Thanks for your help!
/Hans