This may be an XY problem, so first I’ll explain why I’m trying to do this.
We specialize in printed products, and our typical unit of production is a sheet. Each sheet may contain dozens of individual items made to order and/or stock. Most of those items are custom ordered and never printed again, so the individual item part numbers are not in the system. Instead, we have parts for sheets. These parts have the materials for a single printed sheet: one sheet of paper, average amounts of ink, etc. I’m creating jobs where JobHead.PartNum is one of those sheet parts, and the JobPart and JobProd PartNums are the individual item parts. We want JobHead.ProdQty to be the number of sheets, because GetDetails seems to set job materials based on PartNum materials times ProdQty.
The problem is that Update is very persistent in setting ProdQty to the sum of the JobProd quantities. As hinted at in this answer, this is probably the intended behavior in normal use cases.
The number of sheets is saved in a custom field, so I tried to copy it to JobProd in a BPM on both pre and post of Update. If I do it in pre, Update resets JobProd after I change it. If I do it in post, I see my expected value in the output dataset, but as I would expect, it’s not persisted.
Is there any way to prevent Update from setting ProdQty? Or set it myself at a point that will be persisted?
Here’s what I tried:
foreach(var row in ttJobHead)
{
var sheets = row.UDField<decimal>("Sheets_c");
if(sheets > 0) {
row.ProdQty = sheets;
row.LockQty = row.LockedQty = true;
}
Db.Validate();
}
Db.SaveChanges();