Currently I have been tasked with reviewing a BPM created by Epicor that is not functioning as expected. Currently with the BPM based on the code below its purpose is to reference orders in the system and when its time to ship the orders if there is a price change the order/part will reflect a new price. It seems that the code is causing incorrect price lists to be retrieved from customers not expected. For example a price list is attached to customer #1242 but its updating the price based on customer #1269. (Guessing they share a common part # and the code retrieves the latest value)
Now my problem is I don't have experience in writing code, I have reviewed code before but to a small extent and from what I listed above that was provided to me. Now what I thought may be an easier practice for me to understand is create a BAQ and reference that in the BPM and utilize the BAQ as a reference for the BPM to update prices.
With researching a few forums and Epicors training material I haven't found a definitive answer on how to link a BAQ in a BPM.
(Also if my description makes sense and the code reflects the issue feel free take a guess)
BPM Code:
var ttShipHead_xRow = (from ttShipHead_Row in ttShipHead
where ttShipHead_Row.ReadyToInvoice == true
select ttShipHead_Row).FirstOrDefault();
if (ttShipHead_xRow != null)
{
foreach (var ShipDtl_iterator in (from ShipDtl_Row in Db.ShipDtl
where ttShipHead_xRow.PackNum == ShipDtl_Row.PackNum
&& ttShipHead_xRow.Company == ShipDtl_Row.Company
select ShipDtl_Row))
{
var ShipDtl_xRow = ShipDtl_iterator;
//ShipDtl_xRow.UnitPrice = 1;
var today = DateTime.Today;
var PriceList_xRow = (from PriceLst_Row in Db.PriceLst
from PriceLstParts_Row in Db.PriceLstParts
where ShipDtl_xRow.PartNum == PriceLstParts_Row.PartNum
&& PriceLst_Row.ListCode == PriceLstParts_Row.ListCode
&& PriceLst_Row.Company == PriceLstParts_Row.Company
&& PriceLst_Row.Company == ShipDtl_xRow.Company
&& PriceLst_Row.EndDate >= today
select PriceLstParts_Row).FirstOrDefault();
if (PriceList_xRow != null)
{
var OrderDtl_xRow = (from OrderDtl_Row in Db.OrderDtl
where ShipDtl_xRow.OrderLine == OrderDtl_Row.OrderLine
&& ShipDtl_xRow.PartNum == OrderDtl_Row.PartNum
&& ShipDtl_xRow.OrderNum == OrderDtl_Row.OrderNum
&& ShipDtl_xRow.Company == OrderDtl_Row.Company
select OrderDtl_Row).FirstOrDefault();
{
if (OrderDtl_xRow != null)
{
if (ShipDtl_xRow.UnitPrice != PriceList_xRow.BasePrice)
{
ShipDtl_xRow.UnitPrice = PriceList_xRow.BasePrice;
}
if (ShipDtl_xRow.UnitPrice != OrderDtl_xRow.UnitPrice)
{
OrderDtl_xRow.DocUnitPrice = PriceList_xRow.BasePrice;
OrderDtl_xRow.UnitPrice = PriceList_xRow.BasePrice;
}
}
}
}
}
}
I resolved the code but still could not determine a valid method to link a BAQ in the BPM
The problem was the following code was missing:
&& ttShipHead_xRow.CustNum == ShipDtl_Row. CustNum
to the first foreach statement.