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

I did and it and my current routine did not have data in the update dataset for the not changed rows in 2023.2.8, so nothing was there to update.

Is there any other way we could look into this?
I have 3 BPMs that would follow this same logic.
Thanks,

I think you have to let the header update complete then post processing update all of the lines by calling GetByID. Update the details lines and then use dsHolder.Attach to update the dataset.

Thank you so much. I’ll try that.

@gpayne
Did you mean to use this?
Erp.BO.SalesOrder.GetByID?

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

Thank you so much. I’ll try this.

@gpayne
I followed the instructions, but I am getting the error below.
Can you please help?

The casing of the fields has to match. I think I noticed your fields had a lower c in one and an upper in another table.

@gpayne Thank you so much, it works now.

Hi @gpayne
I ran into an issue with this. Can you please help?
The boxes are getting checked but it is not getting saved



As you can see on the line level:
image

try adding an update before the holder attach. I can’t test since I have a lot of other bpms on sales order so I don’t know if that will work, but it compiles.

salesBO.Update(ref salesOrder);

I have added the code but it only saves after I check any box on the line level.
Any insights on this?
Thanks.
image

Some other posts about dsHolder.Attach use a transaction scope.

at the top
using (var txscope = IceDataContext.CreateDefaultTransactionScope()) 
{

after dsHolder.attach
txscope.Complete();
}

Add it in the current post-processing custom code?

yes.

At the top of this?

/* update CoCRequired_c */

Ice.Diagnostics.Log.WriteEntry("start update CoCRequired_c");
 
SalesOrderSvcContract salesBO = Ice.Assemblies.ServiceRenderer.GetService<SalesOrderSvcContract>(Db);

using (var txscope = IceDataContext.CreateDefaultTransactionScope()) 
{
            
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>("COCRequired2_c"));
     
     }

}


salesBO.Update(ref salesOrder);
dsHolder.Attach(salesOrder);

txscope.Complete();
}

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

Edited

I believe it would like I changed the code above.

Thank you.
I just tried and it didnt work.
It would save the changes made only when I make changes on the line level anywhere:

Sorry. I don’t what is missing. My last thing to try would be to make the ttOrderDtlRow.RowMod = “U”