Tuesday 3 January 2023

How to substitute a default report with a custom report in Business Central on premise

 

Hello Reader,
If you are reading this then probably you have been checking a couple of resources to find a solution to the stated issue.
I had a similar challenge and after spending a couple of hours checking online resources, I found it very easy !
    
https://microsoft-dynamicsnav.blogspot.com/


Follow these steps.

Create your custom report in a new extension. If you don't know how to create extensions follow this
After creating your Custom report in the extension, you will have to create a code unit with subscriber event to codeunit Report management.

Just publish and run your extension. You should have your reports substitution successful
Here is a sample 
codeunit 100 "GP Base Report Substittuion"
{
    trigger OnRun()
    begin

    end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::ReportManagement,
'OnAfterSubstituteReport', '', false, false)]
    local procedure OnSubstituteReport(ReportId: Integer; var NewReportId: Integer)
    begin
//Reminder is the name of the default report object in Business Central
        if ReportId = Report::Reminder then
            NewReportId := Report::GPReminder;
//GPReminder is the name of the custom report you created to substitute the default
// report
    end;
}

No comments:

Post a Comment