Prevent Update from setting JobHead.ProdQty?

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

I also tried setting ProdQty via REST calls after adding demand:

add demand - update - set ProdQty - set LockQty - update

And

add demand - update - set ProdQty - update - set LockQty - update

I get back a dataset that looks right. But when I look at the job in the UI, ProdQty has been clobbered and LockQty is false again.

I’m not quite sure what the solution would be, but maybe try an in-transaction data directive?

JobHead.ProcessMode seems related:

Concurrent jobs are used where the production time is based on the number of machine operations performed and not on the number of parts created. For example, a stamping operation where each cycle of the machine stamps out x number of parts.

When I set it to “C”, ProdQty is forced to 0 instead of the sum of demand quantities. As before, the last call to Update returns a dataset with the desired values, but then GetDatasetForTree seems to overwrite them.

I don’t know if this is the “right” way to do it, but I found a working solution. I added demand in JobProd with make to stock quantity for JobHead.PartNum. That quantity gets copied to JobHead.ProdQty. I also tried using make to job, but you can’t make to job for the current job.