web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Sales Price Date Range FIlter

(0) ShareShare
ReportReport
Posted on by 5

I am creating a page extension and I would like to reference a field to sales price page. But there are multiple sales price of the same item with different "Start Date" and "End Date". Is it possible to use "Order Date" to filter to the correct sales price. E.g like "Order Date" >= "Starting Date" || "Order Date" <= "Ending Date".

Thanks

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,218 Super User 2026 Season 1 on at

    yes, you can use something like the below code

    SetFilter("Starting Date", '<=%1', "Order Date");

    SetFilter("Ending Date", '>=%1', "Order Date");

  • FongFong Profile Picture
    5 on at

    Hi!

    Thanks for the reply. The sales price field is a flowfield. Can the Setfilter function be used with a flowfield?

    Thanks

  • Suggested answer
    Mohana Yadav Profile Picture
    61,218 Super User 2026 Season 1 on at

    You mean Starting Date and Ending Date fields?

    I dont think they are flowfields

  • FongFong Profile Picture
    5 on at

    Hi,

    I am currently using flowfield to lookup the sales price in the sales price page. In addition I would also like to have a filter like "Order Date" >= "Starting Date" || "Order Date" <= "Ending Date" to filter the correct price based on the "Order Date" .

    Is this possible?

    Thanks

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    Is it a customer specific sales price you are trying to display?

    I would recommend you look into this codeunit codeunit 7001 "Price Calculation Mgt." and see if you can find a function there that will get you the price you want to display instead of using flow fields only on dates.

  • FongFong Profile Picture
    5 on at

    Yes. Its a specific sales price that I am trying to get. Below is my current code using flowfield in table extension:

    tableextension 60300 SalesLineExt extends "Sales Line"

    {

       fields

       {

           // Add changes to table fields here

           field(60300; SellingPrice; Decimal)

           {

               Caption = 'Selling Price';

               FieldClass = FlowField;

               CalcFormula = lookup("Sales Price"."Unit Price"

                               where("Item No." = field("No."),

                                       "Variant Code" = field("Variant Code"),

                                       "Currency Code" = field("Currency Code"),

                                       "Sales Code" = field("Sell-to Customer No."))); 

           }

           field(60320; OrderDate; Date)

           {

               Caption = 'Order Date';

               FieldClass = FlowField;

               CalcFormula = lookup("Sales Header"."Order Date" where("No." = field("Document No.")));

           }

       }

    Screenshot-2023_2D00_03_2D00_21-110205.jpg

    Selling Price field will always return the first row of the price page. I would like to add in the Order Date filter so for e.g: Order Date = 06/02/2021, then it will return the price of the first row. If Order Date = 06/07/2022, then it will return the price of the third row.

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,690 Super User 2026 Season 1

#2
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,091 Super User 2026 Season 1

#3
YUN ZHU Profile Picture

YUN ZHU 1,047 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans