Hi everyone, I could use some extra eyes on this one. I’m attempting to delete some receipt lines for a container from an Epicor function but the usual methods aren’t working.
I’ve tried:
Setting RowMod = “D” then calling Update - No errors, but receipt line remains.
Using ds.RcvDtl.Remove(row) then calling Update - Same as above.
Calling Receipt.DeleteByID - Can’t use as it deletes the entire receipt header!
Running a trace and deleting the line manually shows only the Update method is being called. No rows in ds have RowMod = “D” and the deleted row is gone from ds but I can see a reference to the deleted row in the paramDatasetChanges dataset:
So far I have the following. The receipt lines to delete are fed from a BAQ and the dsReceipts dataset is populated from a BO.Method call earlier in the function.
DataTable dtResults = dsResults.Tables[0];
for(int i = 0; i < dtResults.Rows.Count; i++)
{
DataRow baqRow = dtResults.Rows[i];
string packSlip = baqRow["TL_RcvDtl_PackSlip"].ToString();
int packLine = (int)baqRow["TL_RcvDtl_PackLine"];
this.CallService<ReceiptSvcContract>(
bo =>
{
var receiptLineToDelete = dsReceipts.RcvDtl.First(rcpt => rcpt.Company == Session.CompanyID
&& rcpt.PackSlip == packSlip
&& rcpt.PackLine == packLine);
/*
if(true)
{
throw new Ice.BLException("Receipt line found?: " + (receiptLineToDelete != null));
}
*/
receiptLineToDelete.RowMod = "D";
// dsReceipts.RcvDtl.Remove(receiptLineToDelete);
bo.Update(ref dsReceipts);
}
);
}
That’s really handy to know, I think it should help. Not yet though as I’m now seeing some very weird behaviour with any of the ‘get’ BO methods only returning arrived lines. It’s not returning any that have already been received, despite what the trace is saying
So, looks like the original call to Update was actually working, it’s just the refresh tool in Container Receipt Entry doesn’t refresh all receipt lines for the container. I have to clear out the record then bring it back in again to properly pick up the changes. Gotta love consistency!
My now working ( ) code is below:
DataTable dtResults = dsResults.Tables[0];
for(int i = 0; i < dtResults.Rows.Count; i++)
{
DataRow baqRow = dtResults.Rows[i];
string company = baqRow["TL_RcvDtl_Company"].ToString();
int vendorNum = (int)baqRow["TL_RcvDtl_VendorNum"];
string purPoint = baqRow["TL_RcvDtl_PurPoint"].ToString();
string packSlip = baqRow["TL_RcvDtl_PackSlip"].ToString();
int packLine = (int)baqRow["TL_RcvDtl_PackLine"];
int poNum = (int)baqRow["TL_RcvDtl_PONum"];
int poLine = (int)baqRow["TL_RcvDtl_POLine"];
int poRelNum = (int)baqRow["TL_RcvDtl_PORelNum"];
decimal qty = (decimal)baqRow["TL_RcvDtl_OurQty"];
CallService<ReceiptSvcContract>(
bo =>
{
dsReceipts = bo.GetByID(vendorNum, purPoint, packSlip);
var receiptLineToDelete = dsReceipts.RcvDtl.First(line => line.Company == company
&& line.PackLine == packLine);
receiptLineToDelete.RowMod = "D";
bo.Update(ref dsReceipts);
var arrivedLine = dsReceipts.RcvDtl.First(line => line.Company == company
&& line.PONum == poNum
&& line.POLine == poLine
&& line.PORelNum == poRelNum
&& line.Received == false);
arrivedLine.OurQty = qty;
arrivedLine.Received = true;
arrivedLine.ReceivedComplete = true;
arrivedLine.RowMod = "U";
bo.Update(ref dsReceipts);
}
);
}
For context, this is part of a function to ‘true up’ all PO releases in a container after we’ve received everything.
Due to the size of some of our shipments, we receive against each PO release in multiple receipts (using EKW). We can’t use the ‘Create New’ receipt option as this reduces and closes the related PO release on the first receipt.
The overall function changes the receiving option to ‘Create New’, then deletes and re-submits the last receipt transaction against each PO release that has a shortage.