Proper way to use BPM to update OrderRel

,

@josecgomez
We created a dll and have imported it into epicor. Now, running this code we get a message that says we can’t mark buy-to-order and make direct. Any suggestions? We do not want it make direct.

using (var so = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
				{
					var dp = so.GetByID(orderNum);   //variable 'ds' is changed to 'dp' since 'ds' is already used as a parameter
					for (int i = 0; i < dp.OrderRel.Count; i++)
					{
						if (dp.OrderRel[i].OrderLine == quoteDtl.OrderLine)
						{
							dp.OrderRel[i].RowMod = "U";							
							so.ChangeOrderRelBuyToOrder(true, ref dp);							
							so.Update(ref dp);
						}
					}
				}

I think its cause its already make direct you need to uncheck make direct and then check buy to order.

@josecgomez
How do we do that? i tried both of these before the so.ChangeOrderRelBuyToOrder line but get errors

so.ChangeMake(false, ref dp);
dp.OrderRel[i].Make = false;

@josecgomez
I am running this code:

using (var so = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
				{
					var dp = so.GetByID(orderNum);   //variable 'ds' is changed to 'dp' since 'ds' is already used as a parameter
					for (int i = 0; i < dp.OrderRel.Count; i++)
					{
						if (dp.OrderRel[i].OrderLine == quoteDtl.OrderLine)
						{
							dp.OrderRel[i].RowMod = "U";						
						}
					}
					so.ChangeMake(false, ref dp);
					so.ChangeOrderRelBuyToOrder(true, ref dp);
					so.Update(ref dp);
				} 

This is the error we are getting.

Description: BPM runtime caught an unexpected exception of ‘EntityException’ type.
See more info in the Inner Exception section of Exception Details.
Inner Exception: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)

Even if we comment out change make and changeorderrelbuytoorder we still get the error. Something else is missing.

Try this

using (var txScope = IceContext.CreateDefaultTransactionScope())
{

using (var so = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
				{
					var dp = so.GetByID(orderNum);   //variable 'ds' is changed to 'dp' since 'ds' is already used as a parameter
					for (int i = 0; i < dp.OrderRel.Count; i++)
					{
						if (dp.OrderRel[i].OrderLine == quoteDtl.OrderLine)
						{
							dp.OrderRel[i].RowMod = "U";						
						}
					}
					so.ChangeMake(false, ref dp);
					so.ChangeOrderRelBuyToOrder(true, ref dp);
					so.Update(ref dp);
				} 
}

@danbedwards, @josecgomez

No luck. same error message.

Make sure you wrapped your full transaction with this. I think you started by using a foreach on QuoteDtl?

@danbedwards, @josecgomez

that allowed the code to run without errors however it doesn’t change the make direct nor buy to order. Make direct is still selected and buy to order is still unchecked.

We have it running on post processing on Quote.CreateOrder.

@danbedwards @josecgomez

This is the external method we are calling that runs but nothing seems to have changed:

public void CreateOrder(Erp.Tablesets.QuoteTableset ds, ref System.Int32 orderNum, ref System.String warningMessage, Ice.Tablesets.ContextTableset context)
		{
			using (var txScope = IceContext.CreateDefaultTransactionScope())
			{
				int ordNum = orderNum; 
				foreach (var quoteDtl in (from qd in Db.QuoteDtl
										  join od in Db.OrderDtl.DefaultIfEmpty() on new { qd.Company, qd.QuoteNum, qd.QuoteLine } equals new { od.Company, od.QuoteNum, od.QuoteLine }
										  join orel in Db.OrderRel.DefaultIfEmpty() on new { od.Company, od.OrderNum, od.OrderLine } equals new { orel.Company, orel.OrderNum, orel.OrderLine }
										  join p in Db.Part.DefaultIfEmpty() on new { qd.Company } equals new { p.Company }
										  where qd.ShortChar01 == p.PartNum
										  join pp in Db.PartPlant.DefaultIfEmpty() on new { p.Company, p.PartNum } equals new { pp.Company, pp.PartNum }
										  where (orel.BuyToOrder == false) && (orel.OpenRelease == true) && (od.OrderNum == ordNum) && pp.BuyToOrder == true
										  select new { OrderLine = orel.OrderLine }))
				{
					using (var so = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
					{
						var dp = so.GetByID(orderNum); 
						for (int i = 0; i < dp.OrderRel.Count; i++)
						{
							if (dp.OrderRel[i].OrderLine == quoteDtl.OrderLine)
							{
								dp.OrderRel[i].RowMod = "U";
							}
						}
						so.ChangeMake(false, ref dp);
						so.ChangeOrderRelBuyToOrder(true, ref dp);
						so.Update(ref dp);
					}
				}

			}
		}

I am trying to do something very similar, updating the Sales Order Release NeedByDate from the Job Entry screen when we change the ReqDueDate.

    using(var so = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
    {
        var dp = so.GetByID(oNum);
        for(int i=0; i> dp.OrderRel.Count;i++)
        {
            if(dp.OrderRel[i].OrderRelNum == oRel)
            {
                dp.OrderRel[i].RowMod="U";
                so.ChangeNeedByDate(ref dp, reqDueDate.ToString());
                so.Update(ref dp);
            }
        }
    }

I get a compilation error when saving the Method:

	There is at least one compilation error.
	Update.CommonTypes.cs(472,33): error CS0433: The type 'JobProdTable' exists in both 'Erp.Contracts.BO.JobEntry, Version=10.1.600.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992' and 'Erp.Contracts.BO.SalesOrder, Version=10.1.600.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992'
	Update.CommonTypes.cs(313,55): error CS0433: The type 'JobProdRow' exists in both 'Erp.Contracts.BO.JobEntry, Version=10.1.600.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992' and 'Erp.Contracts.BO.SalesOrder, Version=10.1.600.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992'

Does anyone have any idea on how to get past this issue?

You can create an external BPM or try using an in-tran data directive to get around this. I know a fix is coming to address this issue.

Jose,

We’ve run into the same sort of issue, although with SalesOrder and RMAProc. We’re in 10.1.400.28.

You indicated that the .Dll dataset conflict was resolved for 10.1.600; is this just for the SalesOrder / Quote dataset conflict, or were other dataset conflicts resolved as well ?

Thanks

Ken

BTW, not fixed in 10.2.100.6 in Kanban receipts with an inventory quantity receipts BO added.

Old thread but getting same error using SO BO from JobEntry update. We are on version 10.2.700.
Is it me or the bug still there? Thanks

There is at least one compilation error.
Update.CommonTypes.cs(492,33): error CS0433: The type ‘JobProdTable’ exists in both ‘Erp.Contracts.BO.JobEntry, Version=10.2.700.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.SalesOrder, Version=10.2.700.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
Update.CommonTypes.cs(328,55): error CS0433: The type ‘JobProdRow’ exists in both ‘Erp.Contracts.BO.JobEntry, Version=10.2.700.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.SalesOrder, Version=10.2.700.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’

I’m getting the issue with ‘exists in both’ and when trying to add a Method Directive to Labor.Update().
The exact error is:

The type ‘LaborDtlTable’ exists in both ‘Erp.Contracts.BO.Labor, Version=10.2.600.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.LaborDtl, Version=10.2.600.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’

The issue seems to be that, when I add a variable that uses a library which has a matching type to a type already defined in the Labor Library, the system doesn’t check whether the type is already defined in the added library so adds the new reference and then it isn’t explicitly specifying the library it is getting the type from.
I think I can get away with using custom code and only specifying the variables in there rather than using the variables in the method, but surely this should be fixed by now!