Substituting Reports

It is possible to substitute reports from the base application with “custom reports“. Great!

This can be done by subscribing to the “OnAfterSubstituteReport” event published by  “Codeunit 44 – ReportManagement“.

The following code illustrates “how to subscribe” a method to the “OnAfterSubstituteReport” event. This method replaces the report specified by the ReportId with the one given by the NewReportId parameter.

In this example the "Customer - List" report will be substituted for "My New Customer - List"

codeunit 50100 “Substitute Report”
[EventSubscriber(ObjectType::Codeunit, Codeunit::ReportManagement, ‘OnAfterSubstituteReport’, ”, false, false)]
local procedure

OnAfterSubstituteReport(ReportId: Integer; var NewReportId: Integer)
if ReportId = Report::”Customer – List” then
NewReportId := Report::”My New Customer – List”;

When the “OnAfterSubstituteReport” event is raised, the event subscriber method is called and the replacement takes place.

The event is called OnAfterSubstituteReport to match the pattern followed by other events in the ReportManagement codeunit, but the subscriber will be invoked before the substitution takes place.


Share and Enjoy !


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.