Dynamics 365 Business Central: How to print all type of lines in standard Pro Forma Invoice report – Customization

Dynamics 365 Business Central

Hi, Readers.
Today I would like to briefly talk about a qustion I saw in the Dynamics 365 Community today, how to print all type of lines in standard Pro Forma Invoice report, more details: Not all lines are not printed on ProForma report (dynamics.com)

From sales orders and sales invoices, it’s possible to print out a Pro Forma Invoice.

Because these two documents have not been posted yet, we cannot print the official invoice yet, so BC provides this standard report. You can change the default Pro Forma Invoice in Report Selection – Sales. More details: Report Selection for standard documents (Set up default reports)

This is useful for checking data before posting or for approval outside the system.

But there is a small problem here. Unlike Sales – Confirmation and Sales – Invoice, the Pro Forma Invoice report does not print all lines, only lines with type item will be printed… Let’s look at a simple example.
Sales Order:

Sales – Confirmation:

Pro Forma Invoice:

Why? This is controlled in report 1302 “Standard Sales – Pro Forma Inv”.

So a simple customization is needed if we want to print all types of lines. Let me try it briefly.
1. First we need to remove the Type filter.
PS: Dynamics 365 Business Central: How to remove or cancel only one filter (Not Reset All filter)

2. Because the standard code includes the following line, when you remove the Type filter, the Item table cannot Get the number and will prompt an error.

So we have to skip this line.

Finally, we need to add Item.Get again, otherwise the Item information cannot be obtained.

PS: Item variable is a protected var in report 1302 “Standard Sales – Pro Forma Inv”, so we can access it from the Report Extension.
More details: Dynamics 365 Business Central: Can we access global variables from page extensions or table extensions? Yes, But……

That’s all. Let’s go print it again.

Test video: Youtube

Business Central short video: Print all type of lines in Pro Forma Invoice report – Customization

Give it a try!!!😁

Source code: Github

codeunit 50123 EventHandler
    [EventSubscriber(ObjectType::Report, Report::"Standard Sales - Pro Forma Inv", OnAfterLineOnPreDataItem, '', false, false)]
    local procedure PFInvOnAfterLineOnPreDataItem(var SalesLine: Record "Sales Line")

    [EventSubscriber(ObjectType::Report, Report::"Standard Sales - Pro Forma Inv", OnBeforeGetItemForRec, '', false, false)]
    local procedure PFInvOnBeforeGetItemForRec(var IsHandled: Boolean)
        IsHandled := true;

reportextension 50123 StandardSalesProFormaInvExt extends "Standard Sales - Pro Forma Inv"
            trigger OnBeforeAfterGetRecord()
                if Item.Get(Line."No.") then;


Hope this will help.

Thanks for reading.



Copied title and URL