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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Daily Order Report - Date Issue

(4) ShareShare
ReportReport
Posted on by 765
I am attempting to create an RDL report that shows Sales Orders entered for a given date.  Below is the code.  What is happening is that no matter which Date is used to filter on the Order Date, the first Sales Order record in the list always appears.  For example, the first Sales Order record has an Order Date of 2/3/2025, and if I enter a Date in the report for 2/28/2025, that first record appears along with the correctly dated orders.
 
If I enter a date with no Sales Orders, that same order appears in the report.
 
What am I missing in the code below?
 
If I use the RequestFilterFields (commented out below), it works, but then I am not sure how to provide the filter with a default date value (which I would want to have).  I prefer the Date option in the RequestPage because it allows the date to be picked from a Calendar, but I need to be able to only include the Orders with the correct date.
 
report 50101 "Daily Order Log"
{
    ApplicationArea = All;
    Caption = 'Daily Order Log Report';
    UsageCategory = ReportsAndAnalysis;
    DefaultRenderingLayout = DailyOrderLog;
    dataset
    {
        dataitem(SH; "Sales Header")
        {
            DataItemTableView = where("Document Type" = FILTER('Order'));
            // RequestFilterFields = "Order Date";
            column(OrderDate; "Order Date")
            {
            }
            column(No; "No.")
            {
            }
            column(MasterNo; "Master No.")
            {
            }
            column(BilltoCustomerNo; "Bill-to Customer No.")
            {
            }
            column(ExternalDocumentNo; "External Document No.")
            {
            }
            column(BilltoName; "Bill-to Name")
            {
            }
            column(SalespersonCode; "Salesperson Code")
            {
            }
            column(ShiptoAddress; "Ship-to Address")
            {
            }
            column(ShiptoCity; "Ship-to City")
            {
            }
            column(ShiptoState; "Ship-to County")
            {
            }
            dataitem(SL; "Sales Line")
            {
                DataItemLink = "Document Type" = field("Document Type"),
                             "Document No." = field("No.");
                DataItemTableView = where("Quantity" = FILTER(> 1), "Type" = FILTER("Item"));
                column(ItemDescription; Description)
                {
                }
                column(UnitPrice; "Unit Price")
                {
                }
                column(Qty; Quantity)
                {
                }
                column(ExtPrice; Amount)
                {
                }
                trigger OnPreDataItem()
                begin
                    SH.SetRange("Order Date", OrderDate, OrderDate);
                    // SH.SetFilter("Order Date", '%1', OrderDate);
                end;
            }
        }
    }
    requestpage
    {
        layout
        {
            area(Content)
            {
                group(Options)
                {
                    Caption = 'Options';
                    field(OrderDate; OrderDate)
                    {
                        ApplicationArea = Basic, Suite;
                        Caption = 'Order Date';
                        ToolTip = 'Specifies the Order Date that you want the Orders printed.';
                    }
                }
            }
        }
        actions
        {
            area(Processing)
            {
            }
        }
        trigger OnOpenPage()
        begin
            // if OrderDate = 0D then
            OrderDate := Today();
        end;
    }
    rendering
    {
        layout(DailyOrderLog)
        {
            Type = RDLC;
            LayoutFile = 'DailyOrderLog.rdl';
        }
    }
    var
        OrderDate: date;
}
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    99,055 Super User 2026 Season 1 on at
    Hi, try moving the filter to trigger OnPreReport() first.
     
    Thanks.
    ZHU
  • Suggested answer
    KP - Solution Architect Technical Profile Picture
    658 on at
    Hi
     
    You can try the below OnPreDataitem, it works perfectly
     
     
    Let me know if this helped you.
     
    Thanks,
    KP
  • ME-31032107-0 Profile Picture
    765 on at
    , moving SetRange to the OnPreReport trigger does not perform any data filtering at all.  The entire list of Sales Orders appear in the report.
  • ME-31032107-0 Profile Picture
    765 on at
    , that is what I originally had, and it still includes the first Sales Order in the Order List, with an Order Date that does not match the Date filter.  Neither SetRange nor SetFilter are working correctly.  If I am able to figure out why the first Sales Order record is getting included, then it will work.
  • Verified answer
    ME-31032107-0 Profile Picture
    765 on at
    I figured it out, sometimes you just need to step away and look with a fresh set of eyes.  Turns out I had the OnPreDataItem trigger within the linked Sales Line table, instead of outside the }.  So simple.....
     
    So instead of:
                    column(ExtPrice; Amount)
                    {
                    }
                    trigger OnPreDataItem()
                    begin
                        SH.SetRange("Order Date", OrderDate, OrderDate);
                        // SH.SetFilter("Order Date", '%1', OrderDate);
                    end;
                }
     
    It needed to be:
                    column(ExtPrice; Amount)
                    {
                    }
                }
                    trigger OnPreDataItem()
                    begin
                        SH.SetRange("Order Date", OrderDate, OrderDate);
                        // SH.SetFilter("Order Date", '%1', OrderDate);
                    end;
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,128 Super User 2026 Season 1 on at
    Try this
    trigger OnPreDataItem()
    begin
        SetRange("Order Date", OrderDate, OrderDate);
    end;

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,926 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,158 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 533 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans