So I have extended the Standard - Sales Order Confirmation report:
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;
}
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;
}