I want to restrict user from entering job ship quantity greater then order quantity at customer shipment level in EPICOR Erp.
Created a BPM custom code to check the values and to display a message if there is over shipment. It works fine for the first time. That means while creating a new pack slip and if I am entering job ship quantity more than requested quantity it works fine. But when I unchecked the shipped checkbox then actions->open(ed the shipment) and entered job ship quantity greater than requested quantity the BPM Code does not working.
var ShipDtl = ttShipDtl.Where(sd => (sd.Added()) && ((sd.OurJobShipQty + sd.OurInventoryShipQty) > (sd.SellingReqQty - sd.SellingShippedQty))).FirstOrDefault();
if(ShipDtl != null){
var msg = "You are attempting to overship. Please correct before you can continue.";
msg = msg + ShipDtl.SellingReqQty + " " + ShipDtl.SellingShippedQty + " " + ShipDtl.OurJobShipQty + " " + ShipDtl.OurInventoryShipQty;
throw new Ice.Common.BusinessObjectException(
new Ice.Common.BusinessObjectMessage(msg){
Type = Ice.Common.BusinessObjectMessageType.Error,
}
);
}
Expected result:
An error message if user enters job ship quantity greater than requested quantity(IN full and partial shipment cases of an order)
Change your first line to the following, which should fix the problem:
Your current code specifically is selecting shipping lines only as they are added, but not as they are updated. The
sd.Updated()similarly selects lines whereRowMod == IceRow.ROWSTATE_UPDATED