Skip to content

Extending Reports with Document Central

Document Central can be extended with code to enable automatic archiving when a report is printed or a document is posted or converted. This integration ensures that documents are sent to the Document Central archive queue during the process execution. To activate the archiving, the report must also be configured in the Document Central Report Configuration.

Warning

Extending reports for Document Central 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 Document Central Report Configuration. Checking it will have the same effect as extending your report code. It will lead to the report being archived via the Document Central Report Queue as soon as it is printed from the system, if it was set up in the report setup of Document Central.

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 Document Central module must be licensed.
  • CORE must be available in the extension as a reference.
  • Document Central must be present in the extension as a reference.

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

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;
}