Skip to main content

Notifications

Business Central forum
Unanswered

Duplicate page of a report based on conditions

Posted on by 50
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!
Categories:

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,888 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,247 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans