PartRev and Advanced UOM

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();
  }
}

I also control revs via a BPM+function. It’s attached to Part.Update. So the user won’t see the new rev until he saves, but the whole thing has been bulletproof.

Thanks! I’ll give that a shot.

Putting it on Part.Update gave the same error, and had the same effects.

Rework your code? I don’t think looking for locks is a good practice.

Hello @Ernie Did you get to the bottom of that error?

I didn’t get anything that I could specifically say was the culprit, but when we turned OFF the “Track Inventory By Revision” flag, the problem went away. There was at least one other big issue with that functionality having to do with subassemblies, and I don’t know if that has been resolved or not.

1 Like