Why NAV is so kind … or how to get correct sales price

Some time ago my customer asked me to check why NAV pickups the lowest price in the sales order, whether in sales prices the price for the particular customer was higher.

I said that’s because NAV is very kind system 🙂 and gave him this article,  but business is not always so kind.

So let’s check what we have, and what can we do in next example.

Sales Price

Sales TypeSales CodeItem No.Unit Price
All customers10004500

If we create a sales order for customer 01121212 and sell to him item 1000, then NAV will insert unit price = 4500, and not 5000 as was expected. Why? Because of best price concept

This is written in CU 7000 “Sales Price Calc. Mgt”. FindSalesLinePrice().

Here we have 2 main functions:

  • SalesLinePriceExists(SalesHeader,SalesLine,FALSE); // saves all possible prices for item in temp table. In our example, it will save two prices.
  • CalcBestUnitPrice(TempSalesPrice) //get from saved temp table minimum price. In our example, it will be 4500.

I think this is not correct. If we have an agreement with a certain customer, then we should use prices from this agreement, not prices for all customers, even if they are less. 

How to achieve this? Here is a solution. The idea is to delete all not relevant prices that NAV saves in temp table before it calculates the best price.

1. Insert new function DeleteAlreadyFoundSalesPrice. Don’t forget to use VAR variables.


2. Add this function in CopySalesPriceToSalesPrice function.


After such customization, our example will give 5000, as expected. 

Share Post:

Leave a Reply

About Me


A Microsoft MVP, Business Central architect and a project manager, blogger and a speaker, husband and a twice a father. With more than 15 years in business, I went from developer to company owner. Having a great team, still love to put my hands on code and create AI powered Business Central Apps that just works.

Follow Me

Recent Posts