I need to create a BPM which will check the OurShipQty on the shipment line and compare to the JobProd Qty on the Job Head. If the qtys fall outside of 2% tolerance then error.
For example on a 10kg Job Production. If I try to ship 9.7kgs it would error. If I ship 9.8kgs it will accept.
I have written a baq which works - the expression is below:
You won’t be able to do any calculations in the BPM BAQ, it’s kind of limited (as you have found).
You do have couple of options though. If you have access to that field in the BPM you can use an expression in a condition block. (if you tell me where you are putting your BPM, I can help a little more with that)
If you don’t have access to those fields, you can call that BAQ using the dynamicQueryContract, but that’s going to be a fair amount of code to get that work. So it all depends on what your current skill level is.
It’s a query syntax used by C# similar to SQL but it can be used on many different datasources not just a database, which is nice. It’s more advanced but let’s you do some of the tricky stuff
Hi @carlawhite,
i have done few BPM’s on this area using code, i have altered my code to suite what you want, please let me know if this will work in your environment.
Hi thanks ever so much for your advice. I used your code, and placed it where stated, it works - however, its runs the BPM at time of clicking Shipped on the shiphead
This is too late for our process- it needs to be when the OurJobShipQty is changed. or line is saved.
I tried manipulating your code and placing it on shipdtl in transaction- but still cannot get it working.
Hi Carla,
putting it in there will guarantee that nothing will be shipped if any line is not satisfying this condition, i can change it to other methods, but according to my test experiment, user will be able to pass it by updating other fields or going to the shipping head before hit Save on the ShipDtl UI screen, you can try it and all what you need is to start from ttshipDtl and replace the foreach loop as there is no need to loop through each line of the ttShipHead Pack Id.
@carlawhite
try this, i have re coded it, but used In-Tran data directive on ShipDtl, so it will be triggered on both actions as well as changing Row (notification) event which should give users the early warning as you want
var ttShipDtl_xRow = (from ttShipDtl_Row in ttShipDtl
where ttShipDtl_Row.Company == Session.CompanyID
&& (ttShipDtl_Row.Updated()||ttShipDtl_Row.Added())
select ttShipDtl_Row).FirstOrDefault();
if (ttShipDtl_xRow != null)
{
var JobHead = (from JobHead_Row in Db.JobHead
where JobHead_Row.Company == ttShipDtl_xRow.Company
&& JobHead_Row.JobNum == ttShipDtl_xRow.JobNum
select JobHead_Row).FirstOrDefault();
if (JobHead != null)
{
if(JobHead.ProdQty > ttShipDtl_xRow.OurJobShipQty*1.02m || JobHead.ProdQty < ttShipDtl_xRow.OurJobShipQty*0.98m)
{
CallContext.Current.ExceptionManager.AddBLException("Dispached Qty: "+ttShipDtl_xRow.OurJobShipQty+" of Pack Line No.: "+ttShipDtl_xRow.PackLine+" From Job No.: "+ttShipDtl_xRow.JobNum+" is not within the allowed Job ship Qty tolerance.");
}
}
}
Note: we do not ship from manufacturing in my environment but i advise you to use the code to validate against Part No. as well, because Epicor will allow MFG-CUS Transaction from any Existed Job No.
you can add a widget condition saying when ttShipDtl_xRow.OurJobShipQty changed from any to another and see how Epicor will behave on both BO (i.e. Cust Shipment and Invoicing)