PickedOrders BO: DeleteByID throwing error but deleting record

I found a flaw in my program where it’s not clearing out the record from the PickedOrders table when I unpick a sales order from my code using the IssueReturn BO.
As such, I need a way to delete the record from the PickedOrders table.

Using the BL Tester, when I enter the info to DeleteByID, it’s throwing an error when I delete the record but it still performs the delete:
SQL (record count is 11):


BL Tester:

Error:

SQL After (Record is gone and new record count is 10)

This is goofy as heck and I’m wondering if it’s safe to implement in the code…
Thanks

EDIT: tried this function through the API and it returns the same error yet also deletes the record

Clearly some error in the Epicor code with this.

Epicor code rarely ever calls DeleteByID. Instead, the Epicor code will set the RowMode to a ‘D’ and then call Update. Not all BOs allow Delete but try the RowMode D, Update path to see if you have better results…

I tried a GetByID to return the dataset and then I set the RowMod to D. When invoking Update, it throws a very similar, if not the same, error. In this case, it doesn’t delete the SQL record

Okay - so there you go… BO does not allow Delete and you have identified an error in the DeleteByID logic. Sounds like time for a cool adult beverage.

2 Likes

Crap. Back to the drawing board to figure out the unpick transaction bo I suppose

Did you try unpick and in allocate sequentially… I’ve had luck with that Combo

I used the issue return adapter to do the heavy lifting of the unpick and it does remove it from a picked state but doesn’t remove the picked order record.
I’ll take a look at what you said; which bo does that use?

I think the sales work bench

Agreed, run a trace on fulfillment workbench and then unallocate the order to see if that helps target for you.

For what it’s worth - i know it’s already been determined, but the decomp for that service does in fact show that all Deletion functions are explicitly written to throw that exception. For that matter, the Update() function is the same.

Here’s how I ended up doing it. It’s basically what the handheld Unpick Transaction thing does which utilizes the IssueReturn and UnpickTransaction BO’s. The UnpickTransaction BO is sort of interesting all the methods basically alter a payload that it’s carrying so it’s more simple than I had originally thought.

private void UnpickSalesOrder(UltraGridRow row)
	{
		if((bool)row.Cells["Allocate"].Value)
		{			
			try
			{
				//MessageBox.Show(row.Cells["PartAlloc_OrderNum"].Value.ToString());
				/*Local Variables*/				
				bool userInput = false;
				string legalNumberMsg = string.Empty;
				string partTranPKs = string.Empty;				
				
				int orderNum = (int)row.Cells["PartAlloc_OrderNum"].Value;
				int orderLine = (int)row.Cells["PartAlloc_OrderLine"].Value;
				int orderRelNum = (int)row.Cells["PartAlloc_OrderRelNum"].Value;
				string warehouseCode = (string)row.Cells["PartBin_WarehouseCode"].Value;
				string binNum = (string)row.Cells["PartBin_BinNum"].Value;
				string lotNum = (string)row.Cells["PartBin_LotNum"].Value;

				string opMessage = string.Empty;
				string msg = string.Empty;
				/*Instantiate IssueReturn and PickedOrders*/
				IssueReturnAdapter adapterIssueReturn = new IssueReturnAdapter(oTrans);				
				UnpickTransactionAdapter adapterUnpick = new UnpickTransactionAdapter(oTrans);

				/*Connect to adapters*/
				adapterIssueReturn.BOConnect();			
				adapterUnpick.BOConnect();

				/*Unpick*/
				adapterUnpick.GetNewUnpickTransaction("O");
				adapterUnpick.ChangeOrderNum(orderNum);
				adapterUnpick.ChangeOrderLine(orderLine);
				adapterUnpick.ChangeOrderRelNum(orderRelNum, out opMessage);
				adapterUnpick.ChangeLotNum(lotNum);
				adapterUnpick.ChangeFromWhse(warehouseCode);
				adapterUnpick.ChangeFromBin(binNum);

				adapterUnpick.ChangeToWhse(warehouseCode);
				adapterUnpick.ChangeToBin(binNum);		
				
				adapterUnpick.PreUnpickTransaction(out msg);

				/*Call Issue Return*/
				adapterIssueReturn.GetNewIssueReturn("STK-STK", Guid.Empty, "Unpick");

				//set adapterIssueReturn fields here			
				adapterIssueReturn.IssueReturnData.IssueReturn[0].TranQty = 1;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].PartNum= (string)row.Cells["PartBin_PartNum"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].LotNum= (string)row.Cells["PartBin_LotNum"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].OrderNum = (int)row.Cells["PartAlloc_OrderNum"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].OrderLine = (int)row.Cells["PartAlloc_OrderLine"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].OrderRel = (int)row.Cells["PartAlloc_OrderRelNum"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].FromWarehouseCode = (string)row.Cells["PartBin_WarehouseCode"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].FromBinNum = (string)row.Cells["PartBin_BinNum"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].ToWarehouseCode = (string)row.Cells["PartBin_WarehouseCode"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].ToBinNum = (string)row.Cells["PartBin_BinNum"].Value;
				adapterIssueReturn.IssueReturnData.IssueReturn[0].UM = "EA";

				/*Call Issue Return*/
				adapterIssueReturn.PrePerformMaterialMovement(out userInput);								
				adapterIssueReturn.PerformMaterialMovement(false, out legalNumberMsg, out partTranPKs);
		
				/*Unpick Transaction*/
				adapterUnpick.UnpickTransaction();

				/*Cleanup adapters*/
				adapterIssueReturn.Dispose();
				adapterUnpick.Dispose();
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message.ToString() + "\r\n" + ex.InnerException.ToString());
			}
		}
	}
1 Like