Skip to main content

Notifications

Announcements

No record found.

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

Duplicate page of a report based on conditions

(1) ShareShare
ReportReport
Posted on by 53
Hi community!
 
I am working on a custom report on the shipping label for posted sales invoice/shipment. The shipping labels we use are actually small stickers that will be put on each item we deliver - meaning if a customer orders 1 pc of item A and 2 pcs of item B, we need 1 sticker for item A and 2 stickers for item B.
With my current code, I am only able to print one label for each item regardless of the quantity, and the guys at the warehouse need to print the missing shipping labels manually every time if an item has a qty more than 1.
 
How to modify the codes/RDLC in order to duplicate the report content based on the item quantity? I have read an article on https://divyeshchittenavbc.wordpress.com/2019/11/22/how-to-print-multiple-copies-in-report-in-al-of-microsoft-dynamics-365-business-central-msdyn365bc/ , but I don't know if this is a solution to my case.
 
Here's my code for the shipping label report:
 
report 50153 "Shipping Label WO Invoice"
{
    Caption = 'Shipping Label Without Posted Invoice';
    DefaultRenderingLayout = "Shipping Label Without Invoice";
 
    dataset
    {
        //getting data from Sales Header table instead of Sales Inv Header table
        //if sales invoice has not been posted
        dataitem("Sales Header"; "Sales Header")
        {
            RequestFilterFields = "No.", "Bill-to Customer No.";
 
            column(CompanyName; CompInfo.Name) { }
            column(Picture; CompInfo.Picture) { }
            column(PhoneNo; CompInfo."Phone No.") { }
            column(CustomerName; "Sales Header"."Bill-to Name") { }
            column(OrderNo; "Sales Header"."No.") { }
            column(YourReference; "Sales Header"."Your Reference") { }
            column(ExtDocNo; "Sales Header"."External Document No.") { }
            column(DocDate; "Sales Header"."Document Date") { }
 
            dataitem("Sales Shipment Line"; "Sales Shipment Line")
            {
                DataItemLink = "Order No." = field("No.");
                DataItemTableView = sorting("Order No.", "Line No.");
 
                column(LineNo; "Line No.") { }
                column(ItemNo; "No.") { }
                column(ItemNo2; ItemNo2) { }
 
                trigger OnPreDataItem()
                begin
                    SetRange(Type, "Sales Shipment Line".Type::Item);
                    SetFilter("No.", '<>%1', '');
                end;
 
                trigger OnAfterGetRecord()
                var
                    Item: Record Item;
                begin
                    if Item.Get("No.") then
                        ItemNo2 := Item."No. 2"
                    else
                        ItemNo2 := '';
                end;
            }
        }
    }
 
    requestpage
    {
        SaveValues = true;
    }
 
    rendering
    {
        layout("Shipping Label Without Invoice")
        {
            Type = RDLC;
            LayoutFile = './Objects/ReportLayouts/ShippingLabelWithoutInvoice.rdl';
        }
    }
 
    trigger OnPreReport()
    begin
        CompInfo.Get();
        CompInfo.CalcFields(Picture);
    end;
 
    var
        CompInfo: Record "Company Information";
        ItemNo2: Code[20];
}
 
Thank you!
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,148 Super User 2024 Season 2 on at
    Duplicate page of a report based on conditions
    It sounds like your needs are different from this blog. You need to paginate according to each Item, and the number of pages printed is different, which is related to the number of Items.
    As far as I know, this is difficult to do.
    If the number of items is small, you can consider printing them separately, such as printing A first, then printing B. This should be possible.
     
    Hope this can give you some hints.
    Thanks.
    ZHU

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,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans