OrderDtl UD Field (Decimal) Roll-up to OrderHed

Good Evening. I am looking for help with a BPM or Customization that will Sum or Roll up two OrderDtl UD fields to their corresponding OrderHed UD fields.

These two fields currently display the total Standard and Average Cost of the Order Line (Costs * OrderDtl.Quantity). I would like to roll these up and show at the OrderHed level the total Standard/Average Cost for all Lines or Parts. I know this could probably be done fairly easily with custom code executed through a post processing method or a data directive, but I am not too savvy with C#. Any help would be greatly appreciated!

If you’re ok with using code that you don’t understand, the Following BPM Calculates the totals of fields in the OrderDtl lines, and stores it in the a field in the Order Hed.

image

Two variables:

image

Custom Code Widget:

image

and its code

ExtStdTotal = 0;
ExtAvgTotal = 0;
foreach (var ordDtl in Db.OrderDtl.Where(x => x.Company == callContextClient.CurrentCompany && x.OrderNum == iOrderNum)) {
    // sub your UD fields that has the Std or Avg price for UnitPrice
    ExtStdTotal += ordDtl.OrderQty * ordDtl.UnitPrice; 
    ExtAvgTotal += ordDtl.OrderQty * ordDtl.UnitPrice;
}

The Show Message is just for debugging (I display the ExtStdTotal and ExtAvgTotal )

Set Field 0 Widget
image
(change the target field to be your OrderHed.UD_c field.

image

Set Field 1 is the same as the previous, but with the expression containing the other variable