# Simple BPM - Quantity Adjustment

**URL:** <https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937>\
**Category:** Epicor ERP 10\
**Tags:** bpm\
**Created:** [July 29, 2022, 9:47am UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937 "2022-07-29T09:47:22Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [July 29, 2022, 9:47am UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/1 "2022-07-29T09:47:22Z")

</div>

Hey all,

Any able to help me on this or have done something similar?

I have created a Data Directive BPM on PartTran.Update / Standard

It’s a very simple one but unfortunately the condition doesn’t seem to work correctly. I want it to fire off an email if ExtCost exceeds £1000 basically if the part they’re quantity adjusting cost goes over £1000 then fire an email to relevant people.

But it doesn’t seem to work, I’m getting quantity adjustment costs for £31, £12 - 😕

 ![image](https://www.epiusers.help/uploads/default/original/3X/c/d/cde61d990db66766ebaa3a0c23086aa946ed5465.png)

Thank you  
Aaron

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [July 29, 2022, 10:50am UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/2 "2022-07-29T10:50:03Z")

</div>

I have chosen to write it in a LINQ statement but I can’t seem to get the OR section to work

`Db.PartTran.Where(r =>r.Company == callContextClient.CurrentCompany && r.TranNum == ttPartTranRow.TranNum && r.ExtCost > 1000M).Select(r =>r.ExtCost ).DefaultIfEmpty(0).FirstOrDefault()`

---

<div class="post-metadata">

**Author:** ![TomAlexander](https://www.epiusers.help/user_avatar/www.epiusers.help/tomalexander/32/98890_2.png) [@TomAlexander](https://www.epiusers.help/u/TomAlexander)\
**Post date:** [July 29, 2022, 10:55am UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/3 "2022-07-29T10:55:53Z")

</div>

Data directive on PartTran feels like playing with fire… I would recommend a method directive on the Qty Adjust BO.

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [July 29, 2022, 11:25am UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/4 "2022-07-29T11:25:43Z")

</div>

Are you able to show me an example of how to achieve this correctly?

---

<div class="post-metadata">

**Author:** ![askulte](https://www.epiusers.help/user_avatar/www.epiusers.help/askulte/32/7325_2.png) [@askulte](https://www.epiusers.help/u/askulte)\
**Post date:** [July 29, 2022, 12:37pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/5 "2022-07-29T12:37:30Z")

</div>

Aaron - Did you mean for it to be negative 1000?  
 ![image](https://www.epiusers.help/uploads/default/original/3X/c/e/ceb1b774bb1e9895ae004c2caa07a21977d15c11.png)

Turn on tracing, do the Qty Adjust, and then do the similar thing you did on the data directive, but with the method directive on the BO from the trace. We’ve got 2 for Inventory Qty Adjustments - One for sending an email when someone does a zero cost adjustment, and another to prevent future dates. The email had to have a condition triggered in the Pre to reduce false alarms, while the email is sent in the Post. Its similar, so maybe it’ll help.

 ![image](https://www.epiusers.help/uploads/default/original/3X/1/6/16a3fb57af6c6c6add1486be237798a45a5ffdf3.png)  
 ![image](https://www.epiusers.help/uploads/default/original/3X/6/9/69e3827fa1d9b81b1c3a9adfec5c617f2b69337b.png)  
 ![image](https://www.epiusers.help/uploads/default/original/3X/9/c/9cf927e2509d93cc1eb2004318ce80f3da20c9b5.png)

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [July 29, 2022, 12:59pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/6 "2022-07-29T12:59:50Z")

</div>

What’s the criteria of your ds.InventoryQtyAdj

---

<div class="post-metadata">

**Author:** ![Dragos](https://www.epiusers.help/letter_avatar_proxy/v4/letter/d/59ef9b/32.png) [@Dragos](https://www.epiusers.help/u/Dragos)\
**Post date:** [July 29, 2022, 1:14pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/7 "2022-07-29T13:14:24Z")

</div>

Both of the below are true:

31 \> -1000  
12 \> -1000

Not sure what the minus is doing there. But if you want to check both positive and negative values you’ll need 2 conditions:

ttPartTran.ExtCost \> 1000  
OR  
ttPartTran.ExtCost \< -1000

---

<div class="post-metadata">

**Author:** ![askulte](https://www.epiusers.help/user_avatar/www.epiusers.help/askulte/32/7325_2.png) [@askulte](https://www.epiusers.help/u/askulte)\
**Post date:** [July 29, 2022, 1:55pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/8 "2022-07-29T13:55:49Z")

</div>

TransDate = Today

 ![image](https://www.epiusers.help/uploads/default/original/3X/2/5/253fbdd9937793024fef4e0b571759e710bccf4e.png)

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [July 29, 2022, 2:38pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/9 "2022-07-29T14:38:16Z")

</div>

Is there anyway to get the ExtCost from SetInvQtyAdj?

---

<div class="post-metadata">

**Author:** ![askulte](https://www.epiusers.help/user_avatar/www.epiusers.help/askulte/32/7325_2.png) [@askulte](https://www.epiusers.help/u/askulte)\
**Post date:** [July 29, 2022, 7:43pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/10 "2022-07-29T19:43:36Z")

</div>

Aaron - Not that I see within my BPM. What BO did your trace show? That should contain it. Or you could do Tim’s BPM to set that as a variable from a different table. I’m no C# coder, but it’s pretty straight forward:  
[https://www.epiusers.help/t/simple-one-liner-c-to-retrieve-data-from-a-table/44627/17](https://www.epiusers.help/t/simple-one-liner-c-to-retrieve-data-from-a-table/44627/17)

---

<div class="post-metadata">

**Author:** ![timshuwy](https://www.epiusers.help/user_avatar/www.epiusers.help/timshuwy/32/90122_2.png) [@timshuwy](https://www.epiusers.help/u/timshuwy)\
**Post date:** [July 29, 2022, 9:29pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/11 "2022-07-29T21:29:27Z")

</div>

I see a significant performance problem with the way you have the query assembled… you have linked the ds.inventoryQtyAdj table (which is not really a table but is a memory resident dataset) to a real dataset. The problem is that when SQL gets this, it doesnt run efficiently. Instead, you should get the data from the QtyAdj and put them into variables, and then FILTER PartTran’s criteria with those variables… see this rather large discussion: [BPM SPEED Helpful Hint - be careful how you "Join"](https://www.epiusers.help/t/bpm-speed-helpful-hint-be-careful-how-you-join/53872)

---

<div class="post-metadata">

**Author:** ![Mike\_Tonoyan](https://www.epiusers.help/user_avatar/www.epiusers.help/mike_tonoyan/32/22422_2.png) [@Mike\_Tonoyan](https://www.epiusers.help/u/Mike_Tonoyan)\
**Post date:** [August 29, 2024, 6:18pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/12 "2024-08-29T18:18:57Z")

</div>

Hi Andris,  
Which fields did you use to link the **ds.InventoryQtyAdj** and **ERP.PartTran** tables? Unfortunately, the **ds.InventoryQtyAdj** does not have the **TranNum** field, which would have made it so easy to link them.

---

<div class="post-metadata">

**Author:** ![askulte](https://www.epiusers.help/user_avatar/www.epiusers.help/askulte/32/7325_2.png) [@askulte](https://www.epiusers.help/u/askulte)\
**Post date:** [August 29, 2024, 7:30pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/13 "2024-08-29T19:30:28Z")

</div>

Mike,

I joined it via Partnum, Quantity, and Date.

 ![image](https://www.epiusers.help/uploads/default/original/3X/a/d/ade98223d67c4352c2e0b3869b3549766fca006b.png)

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [August 29, 2024, 7:38pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/14 "2024-08-29T19:38:40Z")

</div>

I look back at this and realise it was amateur hour.

As of today, it would be done differently to protect data integrity.

---

<div class="post-metadata">

**Author:** ![Mike\_Tonoyan](https://www.epiusers.help/user_avatar/www.epiusers.help/mike_tonoyan/32/22422_2.png) [@Mike\_Tonoyan](https://www.epiusers.help/u/Mike_Tonoyan)\
**Post date:** [August 29, 2024, 9:22pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/15 "2024-08-29T21:22:04Z")

</div>

Thanks, Andris.

---

<div class="post-metadata">

**Author:** ![Mike\_Tonoyan](https://www.epiusers.help/user_avatar/www.epiusers.help/mike_tonoyan/32/22422_2.png) [@Mike\_Tonoyan](https://www.epiusers.help/u/Mike_Tonoyan)\
**Post date:** [August 29, 2024, 9:25pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/16 "2024-08-29T21:25:54Z")

</div>

Hi Aaron,  
How would you do it? I need a BPM to send emails whenever the ADJ-QTY extended cost exceeds $500.00.

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [August 29, 2024, 9:45pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/17 "2024-08-29T21:45:39Z")

</div>

I’ll put something together for you.

---

<div class="post-metadata">

**Author:** ![Mike\_Tonoyan](https://www.epiusers.help/user_avatar/www.epiusers.help/mike_tonoyan/32/22422_2.png) [@Mike\_Tonoyan](https://www.epiusers.help/u/Mike_Tonoyan)\
**Post date:** [August 29, 2024, 11:01pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/18 "2024-08-29T23:01:30Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![CSmith](https://www.epiusers.help/user_avatar/www.epiusers.help/csmith/32/50752_2.png) [@CSmith](https://www.epiusers.help/u/CSmith)\
**Post date:** [August 30, 2024, 1:25pm UTC](https://www.epiusers.help/t/simple-bpm-quantity-adjustment/92937/19 "2024-08-30T13:25:15Z")

</div>

FWIW, I would do like this:

1. Erp.InventoryQtyAdj.SetIncentoryQtyAdj / Pre-processing  
a. Is this DMT bypass or \< $500 valued transaction?  
b. (Optional) Display form asking why and ensure user is aware of financial impact of this transaction.  
c. Do I need email based on above conditions? Prep output definitions (if multi company/site send to appropriate managers/distribution lists)  
d. If cancelled or no adjustment needed cancel and zero the AdjQty value else continue in post processing.

 ![image](https://www.epiusers.help/uploads/default/original/3X/7/b/7b0931af8c6952ed49f6467faa7aa9927e4c874d.png)

1. Erp.InventoryQtyAdj.SetIncentoryQtyAdj / Post-processing  
a. Is alert needing sent?  
b. Grab params from preprocessing callContextBpmData  
c. Use params and send email (using email function if available)  
d. Log error on failure to send

 ![image](https://www.epiusers.help/uploads/default/original/3X/b/2/b2ca7c9f0b341b6beff6059ff8f28dae0312ccb3.png)
