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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Custom Report Layouts - Business Central

(0) ShareShare
ReportReport
Posted on by 40

Is it possible to switch between sales invoice report layouts while triggering the operation "Create Sales Invoice" from job planning lines? In other words, is it possible to switch between report layouts before creating a specific report in Business Central ?

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Yes you can. You can replace built-in reports by subscribing to the OnAfterSubstituteReport event emitted by Codeunit 44 - ReportManagement. Substitution is possible whenever a report is invoked as the result of the user activating a page action that has the RunObject property set to a report or a report is invoked through one of the following static methods on the Report data type:

    Run

    RunModal

    SaveAsHtml

    SaveAsXml

    SaveAsPdf

    SaveAsExcel

    SaveAsWord

    RunRequestPage

    Execute

    Print

    SaveAs

    Substitution is performed by setting the value of the NewReportId event parameter to the ID of the report that should replace the report with ID ReportId.

  • Farheen Profile Picture
    40 on at

    Since I am new to this Business Central platform, it would be great if you could help me with detailed steps on the approach that you have mentioned.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Create a codeunit and subscribe to the above event. In this event, you can do like the following:

    codeunit 50100 "Replace Reports"

    {

       [EventSubscriber(ObjectType::Codeunit, Codeunit::ReportManagement, 'OnAfterSubstituteReport', '', false, false)]

       local procedure OnAfterSubstituteReport(ReportId: Integer; var NewReportId: Integer)

       begin

           if ReportId = Report::"Sales Invoice" then

               NewReportId := Report::"My New Sales Invoice";

       end;

    }

    In this event you can write the logic you want for changing the report at runtime.

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 > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans