Programmatically set ReadyToCalc on a OrderHed via function (SetReadyToCalc)

I tried a number of things to get the call working.
Firstly I started by checking what is called by kinetic itself using the inspector, which returned a call to the SetReadyToCalc endpoint.


This was sent with a ds containing only the TaxConnectStatus and the ipOrderNum.
Setting up this exact call achieved absolutely nothing in the end. The ReadyToCalc value was still false, and no tax was calculated.

I found a few conversations on here and tried those. One of which in particular may work for others:

However, it didn’t work with my situation. The end solution:

The dark art of Buffer Copy.

  var orderHed = ds.OrderHed.FirstOrDefault();
  var updatedRow = (Erp.Tablesets.OrderHedRow)ds.OrderHed.NewRow();  
  BufferCopy.Copy(orderHed, updatedRow);
  ds.OrderHed.Add(updatedRow);  
  updatedRow.ReadyToCalc = true;
  updatedRow.RowMod = "U";  

  salesOrderSvc.MasterUpdate(
    true,
    true,
    "OrderHed",
    custNum,
    orderNum,
    false,
    out outbool,
    out outstring,
    out outstring,
    out outstring,
    out outstring,
    out outstring,
    out outstring,
    out outstring,
    out outstring,
    out outstring,
    ref ds
  );

Starting with the freshly updated complete sales order tableset, then using a buffer copy of the entire OrderHed, I was able to trigger everything required in the backend and get the sales order to display with the correct state, ready to process and with taxes calculated.

2 Likes