I’ve got a customer (new install) who wants to increment their Revision Number within a part starting at 1000. So far so good. I’ve got a UD field on the Part table to hold the “next” Revision number, and a Post-Processing Method Directive on Part.GetNewPartRev that both uses that for the new revision AND increments it for the next time.
Except it doesn’t work for Advanced UOM parts. Whenever I try it for those, I get a Server Side Exception that boils down to:
##!Description:##! BPM runtime caught an unexpected exception of ‘EntityCommandExecutionException’ type.
See more info in the Inner Exception section of Exception Details.
##!Inner Exception:##! Attempt to lock records with no transaction in effect detected.
The BPM does two things in a single code block, it copies the UD field into the RevisionNum field, and then it increments the UD field. When I do this and get the error, the UD field gets incremented but the RevisionNum field is not updated. If I remove the line to increment the UD field, the RevisionNum field is updated and there is no error.
Code below:
foreach(var x in ds.PartRev.Where(rd=>rd.RowMod == IceRow.ROWSTATE_ADDED))
{
var partnumber = (from p in Db.Part.With(LockHint.UpdLock) where p.PartNum == x.PartNum select p).FirstOrDefault();
if(partnumber!=null)
{
x.RevisionNum = Convert.ToString(partnumber["RevEnumerator_c"]);
partnumber["RevEnumerator_c"] = Convert.ToInt32(partnumber["RevEnumerator_c"]) + 1;
Db.Validate();
}
}