Hello guys I’m working on a code to update Ship To value from order header by using a method directive and need to change the same value to all releases, by standard behavior when we change manually the value of the ShipTo field and save we got a message about refreshing the lines and releases with the changes if we click on Yes the ShipTo field from the releases is changed to the same value in the header, I tracked the events but I’m not sure if I need to do the change also to the releases table (with the below code only the ShipTo from the header is changed) this is on 10.2.500.
var salesOrderDS = new Erp.Tablesets.SalesOrderTableset();
Erp.Contracts.SalesOrderSvcContract hSalesOrder = null;
hSalesOrder = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db);
int ordernum = 5371;
string shipTo = “Plant1”;
if (hSalesOrder != null)
{
salesOrderDS = hSalesOrder.GetByID(ordernum);
//Update OrderHed ShipTo
var ttOrderHedR = salesOrderDS.OrderHed.FirstOrDefault(x => x.Company.Equals(Session.CompanyID));
if (ttOrderHedR != null)
{
bool TaxPricingFlag;
bool TaxRecalFlag;
ttOrderHedR.ShipToNum = shipTo;
ttOrderHedR.RowMod = "U";
hSalesOrder.OnChangeHeaderShipTo(shipTo, out TaxPricingFlag, out TaxRecalFlag, ref salesOrderDS);
hSalesOrder.ChangeShipToID(ref salesOrderDS);
bool lContinue;
string cResponseMsg;
string cCreditShipAction;
string cDisplayMsg;
string cCompliantMsg;
string cResponseMsgOrdRel;
string cAgingMessage;
hSalesOrder.MasterUpdate(true, true, "OrderHed", 9, ordernum, true, out lContinue, out cResponseMsg, out cCreditShipAction, out cDisplayMsg, out cCompliantMsg, out cResponseMsgOrdRel, out cAgingMessage, ref salesOrderDS);
hSalesOrder.MasterUpdate(false, false, "OrderHed", 9, ordernum, true, out lContinue, out cResponseMsg, out cCreditShipAction, out cDisplayMsg, out cCompliantMsg, out cResponseMsgOrdRel, out cAgingMessage, ref salesOrderDS);
}//End ttOrderHedR
}//End hSalesOrder
//Clear values
hSalesOrder = null;