
Announcements
Hi All while renaming the Batch number i got this error
Cannot edit a record in Purchase lines history (PurchLineHistory). Update on a valid time state table is not allowed without specifying a ValidTimeStateUpdateMode.
what could be the reason ?
need help.
*This post is locked for comments
I have the same question (0)In general I'm very uncomfortable with renaming primary keys in tables. I guess that's what you were trying to do. As you can see, all kinds of issues can occur.
The problem here is that the table in question is a "valid time state" controlled table (msdn.microsoft.com/.../gg861781.aspx). You can't update them as you can normal tables, instead you have to specify a ValidTimeStateUpdateMode. And it seems that the standard AX "rename primary key" functionality doesn't know how to handle this.
In this case you would have to update the record with ValidTimeStateUpdateMode::Correction, which will update the existing record. I would suggest you just try to update it with a job. You will find instructions on how to implement it from the article that I linked.
However if / when the whole primary key renaming has to happen in one transaction, it's a bit more tricky. One option could be the following:
1) Change the batch id of the purchLine to some other batch id, which already exists in the system
2) Rename your batch id
3) Change the batch id of the purch line to the newly renamed batch id
But you are doing this at your own risk. My suggestion is to never update the primary keys in the first place.