Skip to content

Download documents by code from Document Central

In this documentation, we'll create an extension that allows you to download documents from a Document Central entry via code.

The following requirements must be met:

  • DMS by Simova must be present in the extension for reference.

Download file:

The DownloadFile function downloads a document by code.

Overload 1:

Var Name Data Type Subtype Length Description
No ParamRecordSIMDMSDocumentEntry Record "SIM_DMS Document Entry" The Document Central document entry that is downloaded
No ParamDownloadInAppContext Boolean Defines whether the download is performed in the App Context or in the User Context

The function outputs:

Name Data Type Length Description
ReturnBase64FileText Text The downloaded document as Base64

Code Example:

In this example, a document that has been stored on the customer 01121212 and the file name 103035.pdf is downloaded with an App context.

AL
var
    LocalRecordSIMDMSDocumentEntry: Record "SIM_DMS Document Entry";
    LocalRecordSMIDMSModuleSetup: Record "SIM_DMS Module setup";
    LocalCodeunitSIMDMSDownloadMgt: Codeunit "SIM_DMS Download Mgt";
    LocalCodeunitFileManagement: Codeunit "File Management";
    LocalCodeunitTempBlob: Codeunit "Temp Blob";
    LocalCodeunitBase64Convert: Codeunit "Base64 Convert";
    LocalOutStream: OutStream;
begin
    LocalRecordSMIDMSModuleSetup.Get();
    LocalRecordSIMDMSDocumentEntry.Get(LocalRecordSMIDMSModuleSetup."Repository Code", '/2024/', 'DEBITOR', 01121212, '103035.pdf');

    LocalCodeunitTempBlob.CreateOutStream(LocalOutStream);
    LocalCodeunitBase64Convert.FromBase64(LocalCodeunitSIMDMSDownloadMgt.DownloadFile(LocalRecordSIMDMSDocumentEntry, true), LocalOutStream);

    LocalCodeunitFileManagement.BLOBExport(LocalCodeunitTempBlob, LocalRecordSIMDMSDocumentEntry.Filename, true);
end;