I’m trying to create a BPM Method Directive that inserts the ProjectID and two date fields into UD fields of the new SO when creating a Sales Order from Quote. The method is Erp.Quote.CreateOrder and the BPM is under Post-Processing. I’ve been able to return all of the data that I’m needing using the custom code below and showing it in a message…
Erp.Tables.QuoteHed QuoteHed = null;
Erp.Tables.OrderHed OrderHed = null;
Erp.Tables.OrderDtl OrderDtl = null;
int QuotNum = 0;
callContextBpmData.Character01 = “”;
callContextBpmData.Character02 = “”;
callContextBpmData.Character03 = “”;foreach (var OrderDtl_iterator in (from OrderDtl_Row in Db.OrderDtl
where OrderDtl_Row.Company == callContextClient.CurrentCompany
&& OrderDtl_Row.OrderNum == orderNum
select OrderDtl_Row))
{
OrderDtl = OrderDtl_iterator;
QuotNum = Convert.ToInt32(OrderDtl[“QuoteNum”]);
}foreach (var QuoteHed_iterator in (from QuoteHed_Row in Db.QuoteHed
where QuoteHed_Row.Company == callContextClient.CurrentCompany
&& QuoteHed_Row.QuoteNum == QuotNum
select QuoteHed_Row))
{
QuoteHed = QuoteHed_iterator;if (QuoteHed != null) { if (QuoteHed["ProjectID_c"].ToString() != "") { callContextBpmData.Character01 = QuoteHed["ProjectID_c"].ToString(); } if (QuoteHed["NeedByDate"].ToString() != "") { callContextBpmData.Character02 = QuoteHed["NeedByDate"].ToString(); } if (QuoteHed["RequestDate"].ToString() != "") { callContextBpmData.Character03 = QuoteHed["RequestDate"].ToString(); } }
}
Below is the full code that I’m using to gather and insert the necessary data…
Erp.Tables.QuoteHed QuoteHed = null;
Erp.Tables.OrderHed OrderHed = null;
Erp.Tables.OrderDtl OrderDtl = null;
int QuotNum = 0;foreach (var OrderDtl_iterator in (from OrderDtl_Row in Db.OrderDtl
where OrderDtl_Row.Company == callContextClient.CurrentCompany
&& OrderDtl_Row.OrderNum == orderNum
select OrderDtl_Row))
{
OrderDtl = OrderDtl_iterator;
QuotNum = Convert.ToInt32(OrderDtl[“QuoteNum”]);
}foreach (var QuoteHed_iterator in (from QuoteHed_Row in Db.QuoteHed
where QuoteHed_Row.Company == callContextClient.CurrentCompany
&& QuoteHed_Row.QuoteNum == QuotNum
select QuoteHed_Row))
{
QuoteHed = QuoteHed_iterator;if (QuoteHed != null) { foreach (var OrderHed_iterator in (from OrderHed_Row in Db.OrderHed where OrderHed_Row.Company == callContextClient.CurrentCompany && OrderHed_Row.OrderNum == orderNum select OrderHed_Row)) { OrderHed = OrderHed_iterator; if (OrderHed != null) { if (QuoteHed["ProjectID_c"].ToString() != "") { OrderHed["ProjectID_c"] = QuoteHed["ProjectID_c"]; } if (QuoteHed["NeedByDate"].ToString() != "") { OrderHed["FauxNeedByDate_c"] = QuoteHed["NeedByDate"]; } if (QuoteHed["RequestDate"].ToString() != "") { OrderHed["FauxRequestDate_c"] = QuoteHed["RequestDate"]; } Db.OrderHed.Update(OrderHed); } } }
}
And this is the error I’m getting when I try to create the new sales order…
I’ve never came across this error before, and can’t find anywhere online about it. Does anyone have any ideas? Is there another way that I could accomplish the same thing? Thank you for your time and any help you can provide. Have a great day.