Update Child records from Header record

Its me again. Working on a dashboard with updatable fields. The issue I am having is writing a BPM which I believe needs to be a data directive instead of a method directive since I am using a dashboard. What I am specifically trying to do is if Orderhead.Shortchar09 changes the bpm will look at the orderdtl table and find all records equal to the order number and update each line with the same information in orderdtl.ShortChar19

My guess is this will have to be coded which is my worst enemy. Thanks for any help.

Since these are UD fields not used by Epicor Core logic, it is ok to directly update the Db. If these were core fields you were updating, you should use business objects to preserve data integrity rather than updating the Db directly.

using(var txScope = IceContext.CreateDefaultTransactionScope()) 
{
    foreach(var orderHedRow in ttOrderHed.Where(x => x.RowMod == "U" && !String.IsNullOrEmpty(x.UDField<String>("ShortChar09"))))
    {
        foreach(var orderDtlRow in Db.OrderDtl.Where(x => x.Company == orderHedRow.Company && x.OrderNum == orderHedRow.OrderNum))
        {
            orderDtlRow.SetUDField<string>("ShortChar19", orderHedRow.UDField<String>("ShortChar09"));
            Db.Validate();
        }
    }
    txScope.Complete();
}
3 Likes

Thank You !!! Worked Perfectly.