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

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Copy Loop and Printing many copies of report

(1) ShareShare
ReportReport
Posted on by

Hey guys!

So i have following problem, i have to add copy loop functionality to our Posted Sales Shipment Invoice report, and ive been doing HUGE research and red this https://blogs.msdn.microsoft.com/nav/2017/01/24/how-to-implement-a-copy-loop-in-word-report-layouts/   so many times and it still doesnt work. Im using RDLC as my report style.

So i decide ill try to copy copy loop from one of Microsoft reports, but it now generates report for like 2 minutes and displays only 1 page and page numbering doesnt reset. Here is what code looks like.

 

CopyLoop - OnPreDataItem()
NoOfLoops := ABS(NoOfCopies) + Cust."Invoice Copies" + 1;
IF NoOfLoops <= 0 THEN
  NoOfLoops := 1;
CopyText := '';
SETRANGE(Number,1,NoOfLoops);
OutputNo := 1;

CopyLoop - OnAfterGetRecord()
IF Number > 1 THEN BEGIN
  CopyText := Text003;
  OutputNo += 1;
END;
CurrReport.PAGENO := 1;

Code In Layout

...Here is original code...


Shared NoOfCopies as integer

Public Function SetNoOfCopies(Value as integer)
NoOfCopies = Value
End Function

Public Function GetNoOfCopies() As integer
   Return  NoOfCopies
End Function

Also when it finish to generate the report some fields appear blank, but before i added copyloop they were filled with information...

*This post is locked for comments

I have the same question (0)
  • Amol Salvi Profile Picture
    18,698 on at
    RE: Copy Loop and Printing many copies of report

    I would suggest have a look at standard report no 206 Sale Invoice for more understanding

  • Community Member Profile Picture
    on at
    RE: Copy Loop and Printing many copies of report

    I did, thats where i got the code from.

  • Suggested answer
    Shathika Karunaratne Profile Picture
    on at
    RE: Copy Loop and Printing many copies of report

    You need to add few changes to the two parts in the report.

    1. AL Code
    2. RDL Layout

    1. AL Code

    I have pasted the AL Code screen shot for your perusal below and I've used the Sales Invoice Header Table for the example.

    pastedimage1662466446038v2.png

    Add these Global Variables

         NoOfCopies: Integer;
         NoOfLoops: Integer;
         CopyText: Text[30];
         OutputNo: Integer;
    CopyDescLbl: Label 'Copy of Original 1';
    CopyDescLbl2: Label 'Copy of Original 2';

    Add following coding accordingly

    CopyLoop - OnPreDataItem

    pastedimage1662466768505v3.png

    CopyLoop - OnAfterGetRecord

    pastedimage1662466794855v4.png

    As you can see, I have added CopyLoop and PageLoop as a dataitem after the Sales Invoice Header Dataitem. This is logic that we used for C/AL. However, Syntax changes. 

    Here I have defined a value to NoOfCopies as 2 in the OnPreReport Trigger as I only need two copies with the original document. If you need to change the copy count, you can add that field to the Request Page and type it manually. Moreover, it displays two different texts in the two copies if the document is printed previously. if it is printing for the first time it will not display the particular text.

             2. RDL Layout

    Go to the Report Layout and Insert a List by right click on the empty space as shown below. 

    3716.Untitled.png 

    Then add a group to the list on OutputNo and Pagebreak for the same as shown in below,

    pastedimage1662467464628v7.png

    Now add your report body inside the List ad we are done.

    Please do make the answer as a verified answer if you are satisfied

  • Suggested answer
    Amit Baru Profile Picture
    3,037 on at
    RE: Copy Loop and Printing many copies of report

    Hi,

    Follow the below images

    pastedimage1662488222610v1.png

    pastedimage1662488244937v2.png

    Regards

    Amit Sharma

    www.erpconsultors.com

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans