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

Notifications

Announcements

No record found.

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,001 Super User 2025 Season 2 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,001 Super User 2025 Season 2 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
    Inge M. Bruvik Profile Picture
    1,111 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans