Skip to main content

Notifications

Announcements

No record found.

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

  • FongFong Profile Picture
    FongFong 5 on at
    RE: Sales Price Date Range FIlter

    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

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    RE: Sales Price Date Range FIlter

    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
    FongFong 5 on at
    RE: Sales Price Date Range FIlter

    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
    Mohana Yadav Profile Picture
    Mohana Yadav 60,050 Super User 2024 Season 2 on at
    RE: Sales Price Date Range FIlter

    You mean Starting Date and Ending Date fields?

    I dont think they are flowfields

  • FongFong Profile Picture
    FongFong 5 on at
    RE: Sales Price Date Range FIlter

    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
    Mohana Yadav 60,050 Super User 2024 Season 2 on at
    RE: Sales Price Date Range FIlter

    yes, you can use something like the below code

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

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

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans