Thursday, December 29, 2011

Error trying to update record in Dynamics Ax

Strange error when trying to update a record in Dynamics Ax 2009. When trying to save a record a message like the following is showed:


Cannot edit a record in Projects (ProjTable).
An update conflict occurred due to another user process deleting the record or changing one or more fields in the record

In this case is the ProjTable but can be any table. The problem happen when the system was running an instruction like update_recordset.

The solution was run a job using an instruction while select forupdate ....
Inside the while cycle and before start to modify the record values, i wrote the next instruction:

projTable.reread();

All the instruction was something like the following:

ttsbegin;
while select forupdate projTable...
...
{
    projTable.reread();
    .....
    projTable.update();
}
ttscommit;

After run the job the problem was solved and the process with the instruction update_recordset start to work again without problems.

I hope this can help to someone in a similar problem

1 comment:

Unknown said...

Really appreciated for this information :)

I am not a developer , I am just a functional and try to create a new job at VendPaymSchedLine table , and it's as follows:

Static void Razan(Args_args)
{
VendPaymSchedLine vendPaymSchedLine;
ttsBegin;

While Select forUpdate RecId from vendPaymSchedLine

{

vendPaymSchedLine.reread();
vendPaymSchedLine.update();

}

ttsCommit;

}


Is this true code and will be update the error that apperead , when I press the Cash flow forecast button from the Purchase Order Screen.

Thank u again