Im trying to make a BPM which prevents a demand line from being updated based on certain criteria, but Im running into an issue where the exception which is supposed to stop the quantity from being changed works when the save button is clicked, but if the refresh button is clicked after it will enter the quantity typed and update the prod quantity.
Where do you have the stop? You may need to go further up in the trace to stop it earlier.
I have one on ChangeJobProdMakeToStockQty and at the bottom if it fails it sets the quantity back to the previous quantity. I wrote it a long time ago, but I would assume the reset was because of what you are describing.
Yeah that sounds like the solution I would be needing. I did try the Change JobProdMakeToStockQty and tried having it on the JobEntry.Update method, but got the same result for both.
This is the routine. I don’t allow the demand to be changed to less than is already moved to inventory.
/* Check qty received */
object MESSAGE_ERR = null;
string Msg = string.Empty;
Erp.Tables.JobProd JobProd;
Ice.Diagnostics.Log.WriteEntry("start Job prod check make to stock quantity");
foreach (var ttJobProdRow in ds.JobProd.Where(ttJobProd_Row=> ttJobProd_Row.Company == callContextClient.CurrentCompany && ttJobProd_Row.OrderNum == 0 && !ttJobProd_Row.Unchanged() ))
{
Ice.Diagnostics.Log.WriteEntry($"In JobProd {ttJobProdRow.JobNum} MTS Qty is {ttJobProdRow.MakeToStockQty} Rcv:{ttJobProdRow.ReceivedQty} ");
if(ttJobProdRow.MakeToStockQty < ttJobProdRow.ReceivedQty)
{
Ice.Diagnostics.Log.WriteEntry("In JobProd " + ttJobProdRow.JobNum );
Msg = "Cannot reduce Demand less than already received to Inventory of " + ttJobProdRow.ReceivedQty.ToString("#") +"\nClick Undo or Refresh button";
//CallContext.Current.ExceptionManager.AddBLException(Msg);
throw new Ice.BLException(Msg);
var prevQty = ds.JobProd.Where(p=> p.Unchanged()).Select(p=> p.MakeToStockQty).FirstOrDefault();
Ice.Diagnostics.Log.WriteEntry($" Setting from {ttJobProdRow.MakeToStockQty} back to {prevQty}" );
ttJobProdRow.MakeToStockQty = prevQty;
}
}
1 Like