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;
}