How to Modify the behavior in the Price List when using the Customer’s Price Group

A short time ago, I had a support case where the customer showed that the Price List was not working correctly.

After a couple of hours, we were able to identify that the problem was that the Sales Order had a “Bill-to Customer No.” different from the “Sell-to Customer No.“, and the Price Lists are triggered with the “Bill-To Customer No.” only.

I found the challenge I faced interesting, and that is why I want to share it as a post on this Blog.

Replicating the Scenario

Customer Card

To replicate this scenario I have selected the Customer Price Group = CPG1 to Customer 10000 of the company Cronus.

In Fastab Invoicing I have selected Customer 20000

Sales Price List

Then I created a Price List of type Customer Price Group and I assigned Item 1896-S with a price of $100.

Sales Order

Now, I have created a Sales Order with the Customer 10000

As you can see and what was to be expected, the Bill-To is assigning the Customer 20000.

Test 1

If we create a Sales Line with Item 1896-S we will see that it does not take the corresponding Price of $100 from the Price list.

Test 2

If we activate the event that personalizes the desired behavior, considering theSell-to Customer No.” and not the Bill-to Customer No.” as the trigger in the price list, we have the desired effect.

As can be seen, it has taken the price of $100, which was the desired one.

Code

To create the following code, I asked for a little help as at first, I wasn’t sure if it was the right thing to do.

Writing on Yammer and I got 2 responses, and I want to take the moment to thank Christian Bräunlich and Miljan Milosavljevic once again in this way if they ever read me. 🙂

The event to achieve this customization is:

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales Line - Price", 'OnAfterAddSources', '', false, false)]

Which consisted of Re-initialize PriceSourceList and assigning the Customer Price Group of “Sell-to Customer No.” associated with the sales order.

A configuration field was placed to turn the process on or off on the General Ledger Setup page.

Video Test

Conclusion

It’s probably unlikely that someone would need this special behavior in the Price List, but with this post, I wanted to illustrate a way to subscribe to the “OnAfterAddSources” event of the “Sales Line – Price” codeunit.

All the code used in this post is published in the following GitHub link.

There are much more complex configurations in the price list, for more information on how to extend them I share the official Microsoft link https://learn.microsoft.com/

I hope this will help.

1 thought on “How to Modify the behavior in the Price List when using the Customer’s Price Group

  1. Pingback: How to Modify the behavior in the Price List when using the Customer’s Price Group | Pardaan.com

Leave a Reply

Your email address will not be published. Required fields are marked *