Method directive on InventoryQtyAdj.SetInventoryQtyAdj how to query PartTran.ExtCost

I’m new to BPMs in E10, and I am looking to port a BPM I wrote in E9… I put a post process method directive on InventoryQtyAdj.SetInventoryQtyAdj. My goal is if the inventory adjustment is great than $x send an email notification out. In E9 I has some code to query the PartTran.ExtCost to determine this, but I’m not sure how to make such a query in the new E10 BPMs. Any pointers / suggestions how to go about doing this.

PS I’m looking for the best solution and started with a BPM but if there is a better way to achive this I am open to what ever you recommend.

You can create a variable and then assign its value using a Set Variable widget, with the expression being LINQ code, like:

Db.PartTran.Where( r =>r.Company == MyCompany && r.TranNum == ThisTranNum).Select( r =>r.extcost ).DefaultIfEmpty(0).FirstOrDefault()

Replace MyCompany and ThisTranNum as needed.

And if you need to, you can add more criteria to the `Where(…) part of that.

P.S. Probably want to check the adjustment dollar amount using the ABS (or whatever C#'s equivalent), to check for negative changes that exceed the threshold too.

1 Like