Apply a second discount when SalesCategory = PART on the Sales Order lines

Hello everyone

Can anyone offer any ideas?

A second discount needs to be applied to Sales Order lines where the Sales Category is ‘PART’. So far, I have created a BPM that looks up the value ‘18.00’ in User Codes (AFTRMARKET → AFTERDISC → Short Description), converts it to a decimal, and adds it to a custom field on the OrderDtl table called SecondDiscount_c; however, I now need to actually apply this second discount (SecondDiscount_c). I have noticed that when applying a discount via the DiscountPercent field on the Sales Order, the system automatically saves the discount amount to the Discount and DocDiscount fields. How can I apply this second discount?

It recalculates again and only keeps the native discount I applied.

Below would be my approach… you’ll have to massage to work with how you’re populating your second discount.

… I try to avoid messing with stock functionality where ever possible. So… Let’s leave the provided OrderDtl.DiscountPercent alone. We’ll let it do its thing at the end.

In fact, set it to read only!

Now, add (2) Number Boxes above it.

  • One for an initial discount, bound to TransView.FirstDiscount.
  • A second one for your second discount… I bound mine TransView.SecondDiscount.

So, my form now looks like this (i changed the label of the “stock” discount field so you can see I’m not doing anything with it… I just changed the label to TOTAL %, and changed it to read-only):

I then created an event with no trigger to sum my two discounts… and I’m going to put this sum value in the stock OrderDtl.DiscountPercent field.

Row-Update:

Expression: ({TransView.FirstDiscount} ?? 0) + ({TransView.SecondDiscount} ?? 0)

~*~

I then created a second event to call this one…

Trigger: Datatable > Column Changed > TransView > FirstDiscount,SecondDiscount

Since both of my discount columns were tied to TransView, I can trigger this event when either of them change by including them both in the Columns property (comma delimited list).

Since you may be binding yours to OrderDtl.SecondDiscount_c… you’ll need two events here. One with a trigger when your first discount changes, the other to trigger when you second discount changes.

But that’s why I created the initial “CalcDiscount” event… so I can call it whenever I need it via event-next.

~*~

So… now, when either of my discount values in my “entry” boxes change… it will add the two discounts together and will place the total discount % in the stock OrderDtl.DiscountPercent field. At that point (because we didn’t mess around with base behavior/events), the system does its normal events to take that (now combined) “TOTAL” discount % and apply it against the order line.

Adding “Initial Discount”… event fires… 5+0 = 5%

Adding “Second Discount”… event fires… 5+10 = 15%

Removing “Initial Discount”… event fires… 0+10 = 10%