BPM Setup


I’ve been asked to create a BPM that says, if sum(LaborDtl.LaborQty) is greater than (Jobhead.ProdQty + 10) then error message and terminate.

I am looking more for how to set this up. Can’t think of a good way to do this, in general.

I’ve done something similar in a in-trans method directive on Labor.Update. Hardest part was getting the previously reported quantities, but I was able to use a linq statement for that part.

(from laborDtlRows in Db.LaborDtl
where laborDtlRows.Company == callContextClient.CurrentCompany && laborDtlRows.JobNum == ttLaborDtlRow.JobNum && laborDtlRows.OprSeq == ttLaborDtlRow.OprSeq
select laborDtlRows.LaborQty + laborDtlRows.ScrapQty + laborDtlRows.DiscrepQty).DefaultIfEmpty(0).Sum()

You could try using this statement in a “Set Argument/Variable” widget to get the quantities previously reported, then add that to what’s currently being reported. Then throw your error depending on how it compares with the production quantity.

Here’s the statement I used to pull in the production quantity:

(from jobHeadRow in Db.JobHead
where jobHeadRow.Company == callContextClient.CurrentCompany && jobHeadRow.JobNum == ttLaborDtlRow.JobNum
select jobHeadRow.ProdQty).DefaultIfEmpty(0).FirstOrDefault()

1 Like

Thank you for the info!

I’ve not used Set Argument/Variable very often, so not overly familiar. Curious, is this where you put these two statements in, or did you use the custom code?

Yes these 2 statements can go into that widget. You could also use the statements in a custom code block if you set them to a variable. That widget is similar to the “Set Field” one, but you can use your own custom variables with it. You create the variables just by going to that “Variables” tab after selecting any widget:

1 Like