Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

No. of copies for a custom report

(0) ShareShare
ReportReport
Posted on by 50

Hi All, 

 I have created a custom report in that i want to get the no. of copies functionality i have tried but it is not working perfectly can anyone help me, i am sharing my code and the output how it is coming, my doubt is how to and where i have to set the copy and page loop, if i set them correctly, or not due to those my output not coming.

report 50008 " Label Report"
{
ApplicationArea = All;
Caption = 'Label';
UsageCategory = ReportsAndAnalysis;
DefaultLayout = RDLC;
RDLCLayout = './source/layout/Labels.rdl';
dataset
{
dataitem("Sales Header"; "Sales Header")
{
RequestFilterFields = "No.";
column(No_; "No.") { }
column(Sell_to_Customer_No_; "Sell-to Customer No.") { }

column(Bill_to_Customer_Name; "Sell-to Customer Name" + ' ' + "Sell-to Customer Name 2")
{
}
column(Ship_to_Code; "Ship-to Code") { }
column(Ship_to_Name; "Ship-to Name") { }
column(Ship_to_Address; "Ship-to Address" + ' ' + "Ship-to Address 2") { }
column(Ship_to_City; "Ship-to City") { }
column(Ship_to_County; "Ship-to County") { }
column(Ship_to_Post_Code; "Ship-to Post Code") { }
column(SQIT_Country_of_Origin; "SQIT Country of Origin") { }
column(Sell_to_Contact; "Sell-to Contact") { }
column(External_Document_No_; "External Document No.") { }

column(CompanyPicture; companyinfo.Picture) { }
column(CompanyName; UpperCase(Companyinfo.Name)) { }
column(Comp_VATRegNo; Companyinfo."VAT Registration No.") { }
column(CompanyAddress; Address) { }
column(CompanyAddress1; Address1) { }
column(CompanyCity_Country; "City&Country") { }
column(PhoneNo; 'Tel : ' + Companyinfo."Phone No.") { }
column(Phone; Companyinfo."Phone No.") { }
column(FaxNo; 'Fax : ' + Companyinfo."Fax No.") { }
column(Fax; Companyinfo."Fax No.") { }
dataitem(copyloop; Integer)
{
DataItemTableView = sorting(Number);
dataitem(pageloop; Integer)
{
DataItemTableView = sorting(Number) where(Number = const(1));
column(OutputNoNo; OutputNoNo) { }
column(ReportTitleCopyText; StrSubstNo(Text004, CopyText)) { }

}
trigger OnAfterGetRecord()
var
myInt: Integer;
begin
if Number > 1 then begin
Copytext := FormatDocument.GetCOPYText();
OutputNoNo += 1;
end;
end;

trigger OnPreDataItem()
begin
NoofLoops := Abs(NoofCopies) + 1;
Copytext := '';
SetRange(Number, 1, NoofLoops);
OutputNoNo := 1;
end;
}


dataitem("Sales Line"; "Sales Line")
{
DataItemLink = "Document No." = field("No.");
DataItemLinkReference = "Sales Header";
column(ItemNo_; "Sales Line"."No.") { }
column(Line_No_; "Sales Line"."Line No.") { }
column(SQIT_Sampling_No_; "Sales Line"."SQIT Sampling No.") { }
column(Net_Weight; "Sales Line"."Net Weight") { }

dataitem("Warehouse Shipment Line"; "Warehouse Shipment Line")
{
DataItemLinkReference = "Sales Line";
DataItemLink = "Source No." = field("Document No."), "Item No." = field("No.");

dataitem("Sampling Details"; "Sampling Details")
{
DataItemLinkReference = "Warehouse Shipment Line";
DataItemLink = "Sampling No." = field("Sampling No.");


column(SamplingNo_SamplingDetails;
"Sampling No.")
{
}
column(ItemNo_SamplingDetails; "Item No.")
{
}

dataitem("Sampling Result Details"; "Sampling Result Details")
{
DataItemLinkReference = "Sampling Details";
DataItemLink = "Sampling No." = field("Sampling No.");

column(SamplingNo_SamplingResultDetails; "Sampling No.")
{
}
column(LineNo_SamplingResultDetails; "Line No.")
{
}
column(ElementCode_SamplingResultDetails; "Element Code")
{
}
column(ConcentrationQtyPPMwt_SamplingResultDetails; "Concentration Qty (PPM wt)")
{
}
column(ConcentrationPPMwt_SamplingResultDetails; "Concentration % (PPM wt)")
{
}

}
dataitem("Packing Details"; "Packing Details")
{
RequestFilterFields = "Package No.";
DataItemLinkReference = "Sales Line";
DataItemLink = "Source No." = field("Document No.");
column(Gross_Weight; "Gross Weight") { }
column(Net_WeightPackingDetails; "Net Weight") { }
column(Tare_Weight; "Tare Weight") { }
column(Package_No_; "Package No.") { }
column(Pallet_ID; "Pallet ID") { }

}
}
}
}
}


}
requestpage
{
layout
{
area(content)
{
group(Filters)
{
field(NoofCopies; NoofCopies)
{
Caption = 'No. of Copies';
ApplicationArea = All;
}
}
}
}
actions
{
area(processing)
{
}
}
}

trigger OnPreReport()
var
myInt: Integer;
begin
companyinfo.Get();
companyinfo.CalcFields(companyinfo.Picture);
Address := Companyinfo.Address + ',' + Companyinfo."Address 2";
Address1 := Companyinfo."Phone No." + ',' + Companyinfo."Fax No.";
Country.Reset;
Country.SetRange(Country.Code, Companyinfo."Country/Region Code");
if Country.FindFirst then CountryName := Country.Name;
"City&Country" := Companyinfo.City + ', ' + CountryName;

end;

var
companyinfo: Record "Company Information";
Address: Text[200];
Address1: Text[200];
"City&Country": Text[200];
Country: Record "Country/Region";
CountryName: Text[100];
NoofCopies: Integer;
NoofLoops: Integer;
Copytext: Text[30];
OutputNoNo: Integer;
Text004: Label 'Label %1';
FormatDocument: Codeunit "Format Document";

}

The output is coming like this when i try to print for 2 copies and in the layout i have kept the list and then given the group properties for outputNo and given the page breaks also, i am not using any set data for this one because i dont want names for the copies and page no. also.

pastedimage1684330598138v1.png

pastedimage1684330614045v2.png

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: No. of copies for a custom report

    then try to debug the problem, I am sure you will find the solution.

  • Sarath9999 Profile Picture
    Sarath9999 50 on at
    RE: No. of copies for a custom report

    Hi Nitin,

                   Thank you for suggesting me the solution I have tried your code but the output is coming in the same way as I kept the screenshots before

    Thanks & regards

    Satish

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: No. of copies for a custom report

    Hi,

    You can try this, I did a little bit changes.

    report 66003 "Label Report"
    {
        ApplicationArea = All;
        Caption = 'Label';
        UsageCategory = ReportsAndAnalysis;
        DefaultLayout = RDLC;
        RDLCLayout = './source/layout/Labels.rdl';
        dataset
        {
            dataitem("Sales Header"; "Sales Header")
            {
                RequestFilterFields = "No.";
                column(No_; "No.") { }
                column(Sell_to_Customer_No_; "Sell-to Customer No.") { }
    
                column(Bill_to_Customer_Name; "Sell-to Customer Name"   ' '   "Sell-to Customer Name 2") { }
                column(Ship_to_Code; "Ship-to Code") { }
                column(Ship_to_Name; "Ship-to Name") { }
                column(Ship_to_Address; "Ship-to Address"   ' '   "Ship-to Address 2") { }
                column(Ship_to_City; "Ship-to City") { }
                column(Ship_to_County; "Ship-to County") { }
                column(Ship_to_Post_Code; "Ship-to Post Code") { }
                column(SQIT_Country_of_Origin; "SQIT Country of Origin") { }
                column(Sell_to_Contact; "Sell-to Contact") { }
                column(External_Document_No_; "External Document No.") { }
    
                column(CompanyPicture; companyinfo.Picture) { }
                column(CompanyName; UpperCase(Companyinfo.Name)) { }
                column(Comp_VATRegNo; Companyinfo."VAT Registration No.") { }
                column(CompanyAddress; Address) { }
                column(CompanyAddress1; Address1) { }
                column(CompanyCity_Country; "City&Country") { }
                column(PhoneNo; 'Tel : '   Companyinfo."Phone No.") { }
                column(Phone; Companyinfo."Phone No.") { }
                column(FaxNo; 'Fax : '   Companyinfo."Fax No.") { }
                column(Fax; Companyinfo."Fax No.") { }
                dataitem(copyloop; Integer)
                {
                    DataItemTableView = sorting(Number);
                    dataitem(pageloop; Integer)
                    {
                        DataItemTableView = sorting(Number) where(Number = const(1));
                        column(OutputNoNo; OutputNoNo) { }
                        column(ReportTitleCopyText; StrSubstNo(Text004, CopyText)) { }
    
                    }
                    trigger OnAfterGetRecord()
                    var
                        myInt: Integer;
                    begin
                        if Number > 1 then begin
                            Copytext := FormatDocument.GetCOPYText();
                            OutputNoNo  = 1;
                        end;
                        CurrReport.PAGENO := 1;
                    end;
    
                    trigger OnPreDataItem()
                    begin
                        NoOfLoops := ABS(NoOfCopies)   1;
                        IF NoOfLoops <= 0 THEN
                            NoOfLoops := 1;
                        CopyText := '';
                        SETRANGE(Number, 1, NoOfLoops);
                        OutputNo := 1;
                    end;
                }
    
    
                dataitem("Sales Line"; "Sales Line")
                {
                    DataItemLink = "Document No." = field("No.");
                    DataItemLinkReference = "Sales Header";
                    column(ItemNo_; "Sales Line"."No.") { }
                    column(Line_No_; "Sales Line"."Line No.") { }
                    column(SQIT_Sampling_No_; "Sales Line"."SQIT Sampling No.") { }
                    column(Net_Weight; "Sales Line"."Net Weight") { }
    
                    dataitem("Warehouse Shipment Line"; "Warehouse Shipment Line")
                    {
                        DataItemLinkReference = "Sales Line";
                        DataItemLink = "Source No." = field("Document No."), "Item No." = field("No.");
    
                        dataitem("Sampling Details"; "Sampling Details")
                        {
                            DataItemLinkReference = "Warehouse Shipment Line";
                            DataItemLink = "Sampling No." = field("Sampling No.");
    
    
                            column(SamplingNo_SamplingDetails;
                            "Sampling No.")
                            {
                            }
                            column(ItemNo_SamplingDetails; "Item No.")
                            {
                            }
    
                            dataitem("Sampling Result Details"; "Sampling Result Details")
                            {
                                DataItemLinkReference = "Sampling Details";
                                DataItemLink = "Sampling No." = field("Sampling No.");
    
                                column(SamplingNo_SamplingResultDetails; "Sampling No.")
                                {
                                }
                                column(LineNo_SamplingResultDetails; "Line No.")
                                {
                                }
                                column(ElementCode_SamplingResultDetails; "Element Code")
                                {
                                }
                                column(ConcentrationQtyPPMwt_SamplingResultDetails; "Concentration Qty (PPM wt)")
                                {
                                }
                                column(ConcentrationPPMwt_SamplingResultDetails; "Concentration % (PPM wt)")
                                {
                                }
    
                            }
                            dataitem("Packing Details"; "Packing Details")
                            {
                                RequestFilterFields = "Package No.";
                                DataItemLinkReference = "Sales Line";
                                DataItemLink = "Source No." = field("Document No.");
                                column(Gross_Weight; "Gross Weight") { }
                                column(Net_WeightPackingDetails; "Net Weight") { }
                                column(Tare_Weight; "Tare Weight") { }
                                column(Package_No_; "Package No.") { }
                                column(Pallet_ID; "Pallet ID") { }
    
                            }
                        }
                    }
                }
            }
    
    
        }
        requestpage
        {
            layout
            {
                area(content)
                {
                    group(Filters)
                    {
                        field(NoofCopies; NoofCopies)
                        {
                            Caption = 'No. of Copies';
                            ApplicationArea = All;
                        }
                    }
                }
            }
            actions
            {
                area(processing)
                {
                }
            }
        }
    
        trigger OnPreReport()
        var
            myInt: Integer;
        begin
            companyinfo.Get();
            companyinfo.CalcFields(companyinfo.Picture);
            Address := Companyinfo.Address   ','   Companyinfo."Address 2";
            Address1 := Companyinfo."Phone No."   ','   Companyinfo."Fax No.";
            Country.Reset;
            Country.SetRange(Country.Code, Companyinfo."Country/Region Code");
            if Country.FindFirst then CountryName := Country.Name;
            "City&Country" := Companyinfo.City   ', '   CountryName;
    
        end;
    
        var
            companyinfo: Record "Company Information";
            Address: Text[200];
            Address1: Text[200];
            "City&Country": Text[200];
            Country: Record "Country/Region";
            CountryName: Text[100];
            NoofCopies: Integer;
            NoofLoops: Integer;
            Copytext: Text[30];
            OutputNoNo: Integer;
            Text004: Label 'Label %1';
            FormatDocument: Codeunit "Format Document";
    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans