I have a strange problem in doing transactions through NAV 2009 Web Service.
I pushed web service for sales order in Navision Once it published , a codeunit will parse the XML Document and then insert data into a table , in the same codeunit I have written a COMMIT after data inserted into the table (So that whatever code is executed after this “COMMIT” shouldn’t roleback the insertion of data in table).After commit statement I have called another codeunit that will create a Sales Order based on the data inserted in table.
During this process of creating Sales Order if any error comes, then the sales order creation process should be rolled-back (till the last commit) and a error log to be created in Nav. Although the data inserted in table shouldn’t rollback (as COMMIT was written after that).
Now the problem is if an error comes in the sales order creation then nothing happened in Navision and no data inserted in any table despite using explicit COMMIT after inserting the data into the Table and before calling sales order creation process.
Rather than pushing XML through NAV 2009 Web Service, if I provide the physical path to the XML file and then run the same process than it will insert data in XMLBuffer table and if any error comes in sales order creation process, than it creates a error log else creates a sales order successfully.
Can you suggest what can be done so that system treats it as 2 processes, called one after other, first process parses the XML and inserts into table and second creates sales order using the inserted data. If error comes in 2nd process, first one doesn’t Role Back.
0
Comments
Hi
It's a know bug of Nav WebService:
Transactions are not saved in the Microsoft Dynamics NAV 2009 database when you execute the transactions by using Web services (KB973416).
There is a downlodable Hotfix for this. Require a valid Login.
Nav2009 SP1 should be ok.
Bye
Matteo
Webservices ignore all the commits.
I would structure your code with if CODEUNIT.RUN wrap the error.
Or another option is to have two webservice function. The first one insert the record. The second tries to creates the Order.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
hi ara3n,
On KB973416, Microsoft resolved this Commit issue.. change the architecture for a resolved bug i think is a bit invasive... (imho)...
Matteo
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
To me it made good sense, since it is complex to teach a web developer the issues with Navision commits, since they would need to debug lots of Navision code to find out where the commits were and why. This way the web developer can work in a way they are used to.
I like the way the NAV5 Mobile solution handles it. It simply marks a record as inconsistant, so it fails if it encounters any commits. Then developers could simply disable this commit protection for the selected services, but as a default it should prevent commits. If it instead disabled the commits function, it could be fatal when having code that integrates to other systems via i.e. automations.
Peter
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!