Skip to content

Extending Reports with DMS

In this documentation we will create an extension that extends a report in Business Central with DMS. Extending a report with DMS code is used so that when a report is printed or a document is posted/converted, it is possible to automatically archive it during that process. The archiving will be done over the DMS archive queue. After a report has been extended, it still has to be configured in the DMS Report Configuration in order to activate the archiving.

Warning

Extending reports for DMS is not required anymore from version 21.16.6.0 (BC 21), 22.7.6.0 (BC22) and 23.3.6.0 (BC23). The new, very easy way is to use the print event integration and utilize the checkmark "Print on Event" from the DMS Report Configuration. Checking it will have the same effect as extending your report code. It will lead to the report being archived via the DMS Report Queue as soon as it is printed from the system, if it was set up in the report setup of DMS.

There are two ways to add the necessary code to reports:

In case of an own report, you can add the code directly to the report. With other reports you can create a report extension which will execute the code.

The following requirements must be met:

  • The DMS module must be licensed.
  • CORE by Simova must be available in the extension as a reference.
  • DMS by Simova must be present in the extension as a reference.

Code for the extension of a Business Central report with DMS:

AL
reportextension 5492913 "SIM_DMS Sales Quote Ext" extends "Standard Sales - Quote"
{
    trigger OnPostReport()

    var
        LocalCodeunitSIMDMSArchiveMgt: Codeunit "SIM_DMS Archive Mgt";
        LocalCodeunitSIMDMSSI: Codeunit "SIM_DMS SI";
        LocalCodeunitSIMDMSMgt: Codeunit "SIM_DMS Mgt.";
        LocalRecordRef: RecordRef;
        LocalReportIDInteger: Integer;
    begin

        if not EVALUATE(LocalReportIDInteger, COPYSTR(CurrReport.OBJECTID(FALSE), 7)) then exit;
        LocalCodeunitSIMDMSSI.SetRequestPage(LocalCodeunitSIMDMSMgt.GetRequestPageXML(LocalReportIDInteger));

        LocalRecordRef.GETTABLE(Header);
        LocalCodeunitSIMDMSArchiveMgt.OnReportPostDataItem(LocalRecordRef, LocalReportIDInteger, CurrReport.PREVIEW);
    end;

    procedure HasDMSReportExtensionSIM_DMS(): Boolean
    begin
        exit(true);
    end;
}