Access & update all rows of orderdtl table from sales order entry

Yes. I borrowed some code from @klincecum here to fix my routine and the code below should work for you. pre processing have a condition that check for the field to change and enable a post processing directive. Then in post processing have a condition that this directive was enabled from and then set the code below. in a custom code block.

/* update CoCRequired_c */

Ice.Diagnostics.Log.WriteEntry("start update CoCRequired_c");

          
SalesOrderSvcContract salesBO = Ice.Assemblies.ServiceRenderer.GetService<SalesOrderSvcContract>(Db);
            
SalesOrderTableset salesOrder = salesBO.GetByID(iOrderNum);
            


foreach (var ttOrderHeadRow in (from ttOrderHead_Row in salesOrder.OrderHed select ttOrderHead_Row))
{


    foreach (var ttOrderDtlRow in (from ttOrderDtl_Row in salesOrder.OrderDtl select ttOrderDtl_Row))
    {
    
     Ice.Diagnostics.Log.WriteEntry($" In OrderDtl {ttOrderDtlRow.OrderNum}  CoCRequired_c {ttOrderDtlRow.UDField<bool>("CoCRequired_c")}");
      ttOrderDtlRow.SetUDField<bool>("CoCRequired_c",ttOrderHeadRow.UDField<bool>("CoCRequired_c"));
    
    }

}


dsHolder.Attach(salesOrder);

Ice.Diagnostics.Log.WriteEntry("End update CoCRequired_c");

2 Likes