reportextension 50003 "Custom Sales-Order Con" extends "Standard Sales - Order Conf."
{
dataset
{
addfirst(Header)
{
dataitem("Caja"; "Caja")
{
//JUST A RELATION WITH A CUSTOM TABLE
DataItemLink = "Document No." = field("No.");
DataItemLinkReference = Header;
DataItemTableView = where(Anticipo = const(true));
column(anticipo_Fecha; "Fecha pago") { }
//WITH THIS FUNCTION I FILTER MY DATAITEM USING THE GLOBAL VARIABLE
trigger OnPreDataItem()
begin
if anticipoDate = 0D then
CurrReport.Skip()
else
SetRange("Caja"."Fecha pago", anticipoDate);
end;
}
}
}
//A NEW GLOBAL VARIABLE
var
anticipoDate: Date;
//A PROCEDURE TO SET THE NEW GLOBAL VARIABLE
procedure setAnticipoDate(parmDate: Date)
begin
anticipoDate := parmDate;
end;
}
Now from a page action, i call this report:
action(print)
{
ApplicationArea = All;
Caption = 'Imprimir Prepago';
Image = PrintAttachment;
trigger OnAction()
var
reportPrepago: Report "Standard Sales - Order Conf.";
recFilter: Record "Sales Header";
datefilter: Date;
RLS: Record "Report Layout Selection";
begin
recFilter.SetRange("Document Type", "Document Type"::Order);
recFilter.SetRange("No.", Rec."Document No.");
reportPrepago.SetTableView(recFilter);
RLS.SetTempLayoutSelected('1305-000003'); //This is just to force a custom design for the report
reportPrepago.setAnticipoDate(Rec."Fecha pago"); //I CALL MY FUNCTION TO SET THE GLOBAL VARIABLE
reportPrepago.RunModal();
RLS.SetTempLayoutSelected('');
end;
}
Once the request page opens, if I choose to PRINT the report, everything works as expected, the filter is correctly applied to my custom DataItem. However, the problem is in the page preview, the Global Variable is cleared, and my dataitem is not even filtered.
Maybe it has something to do with this blog post by Stefano Demiliani , but I have no idea how can I avoid this behaviour:
Using OnPremise BC 21.1.48363