Hi everyone,
I am a developer working on a job that my customer needs to fix some wrong intercompany orders. Don't ask me why or how they have done it, as I don't know what they have done to have this situation: I just know that they have some intercompany orders not aligned in delivery remain quantities between the purchase and the sales order and I have been ask for a job that should show a dialog to select a specific purchase or sales order and a lot ID and update its delivery reminder fields to zero.
After some work I have managed to get the job work: tested on the first purchase line of a purchase order, it puts zero on the right fields and still keep the intercompany connections and the rest of the orders fields safe.
But if I load the job a second time and use it to fix a second line of the same purchase order, then I get the error "Cannot edit a record in Purchase orders (PurchTable). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record."
It seems that the first execution of the job leaves the updated purchTable record occupied, and it cannot be updated or deleted anymore, and I am not able to understand why: I put all the modifications to database fields insite da ttsbegin-ttscommit block, so when the first execution of the jobs finish it should unlock any of the used records.
I have read somewhere on this forum that when "delivery reminder" functionality is in use, sometimes this thing could happen... but still I don't know how to fix my job to avoid this.
Is there anyone here that can help? Do you need any more informations?
Thank you!
I moved the thread to Dynamics 365 Finance Forum.
I know little about your code, but let me demonstrate a typical example of what may happen. You can use the debugger to analyze your particular scenario.
Here is the typical case:
1. You read PurchTable record to a variable (e.g. pt). RecVersion is (say) 1.
2. You update a PurchLine record. Some code called from on PurchLine.update() updates some information on PurchTable too, which gets a new RecVersion.
3. Then you use your pt variable to update the status. The system checks whether the version in DB is still 1 and therefore the update can be safely done, and it finds that RecVersion changes and the update could lead to data loss/inconsistency. Therefore it throws an exception.
The right approach in this case is loading the PurchTable record from DB after it was updated by PurchLine.update().
Hi Martin!
I am using dynamics 365 version 10.0.29.
I am still developing the job, so we are talking about a cloud-hosted dev machine: no other users are using it at the same time as me.
As said, the job works on just one specific purchline retrieved through lot ID, but it updates the purchline and purchtable status too in the process. Everything is inside a tts block, so if anything goes wrong it can do a rollback to the original situation.
First time the job works well and with no error. Then, if I use it again on another purch line of the same order (same purch ID and different Lot ID) I get the error. But it's a completely different and separated execution of the job, it can happens hours later from the first one and the problem is the same. So, I don't think there is other executing code that conflicts. But maybe I am wrong...
First of all, which version of AX is it about?
You get an update conflict when you read record from database and before you save it (update()), the record in database gets changed. It may be done by another user, but it might also by your own code updating the same record through a different table buffer.
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,817
Most Valuable Professional
nmaenpaa
101,156