Update an OrderRel on addition

SOLUTION:

Post Method Directive on the SalesOrder.MasterUpdate

Erp.Tables.OrderHed OrderHed;
Erp.Tables.OrderDtl OrderDtl;

callContextBpmData.Number02 = 0;

var OrderHed_Recs = (from OrderHed_Row in Db.OrderHed
where OrderHed_Row.Company == Session.CompanyID
&& OrderHed_Row.OrderNum == callContextBpmData.Number01
select OrderHed_Row).FirstOrDefault();
{
var OrderHedRow = OrderHed_Recs;
if (OrderHed_Recs != null)
{
foreach (var OrderDtl_Recs in (from OrderDtl_Row in Db.OrderDtl
where OrderDtl_Row. Company == Session.CompanyID
&& OrderDtl_Row.OrderNum == OrderHed_Recs.OrderNum
&& OrderDtl_Row.ProdCode != “1WG”
&& OrderDtl_Row.ProdCode.StartsWith(“1”)
select OrderDtl_Row))
{
var OrderDtlRow = OrderDtl_Recs;
if (OrderDtl_Recs != null)
{
if (OrderDtl_Recs.OrderLine > callContextBpmData.Number02)
{
callContextBpmData.Number02 = OrderDtl_Recs.OrderLine;
}
}

} /*** OrderDtl /
}
} /
OrderHed ****/

using (var txscope1 = IceDataContext.CreateDefaultTransactionScope())
{
var OrderRel_Recs = (from OrderRel_Row in Db.OrderRel
where OrderRel_Row.Company == Session.CompanyID
&& OrderRel_Row.OrderNum == callContextBpmData.Number01
&& OrderRel_Row.OrderLine == callContextBpmData.Number02
&& OrderRel_Row.OrderRelNum == 1
select new {OrderRel_Row}).FirstOrDefault();
{
if (OrderRel_Recs != null)
{
OrderRel_Recs.OrderRel_Row.Make = false;
Db.Validate(OrderRel_Recs.OrderRel_Row);
}
} /*** OrderRel ***/

txscope1.Complete();
}

var svc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db);
this.dsHolder.Attach(svc.GetByID(iOrderNum));

Brenda

1 Like

Interesting…I read through this entire thread but did not see anything regarding why you want to do this.
First, there is built in logic within the application and I am not sure if that has been addressed.

  1. If the part is not in the part table, then any part number you add on a sales order will always be either make direct or purchase direct. There is no way to change this if the part is not in the part table.
  2. If the part is in the part dataset(part, partplant, etc) then the app is going to look at the non-stock field on the partplant (site tab in part set up). If the non-stock is checked, then the release line will always be make direct for a mfg part or purchase direct for a purchased part.
  3. If the non-stock check box is clear, then the app assumes the order will pull from inventory. Checking the make direct will tell the app you expect a job and it will ignore any on hand inventory that you have for said part.

Not sure if this sheds any light…