Ga naar inhoud

Documenten downloaden via code vanuit Document Central

Document Central kan worden uitgebreid met code waarmee documenten gedownload kunnen worden vanuit een Document Central-invoer. De onderstaande documentatie legt uit hoe je een extensie maakt waarmee je documenten kunt downloaden via code uit een Document Central-invoer.

De volgende vereisten moeten worden voldaan:

  • Document Central moet aanwezig zijn in de extensie als referentie.

Download bestand:

De functie DownloadFile downloadt een document via code.

Overload 1:

Var Naam Gegevenstype Subtype Lengte Beschrijving
Nee ParamRecordSIMDMSDocumentEntry Record "SIM_DMS Document Entry" De Document Central documentinvoer die wordt gedownload
Nee ParamDownloadInAppContext Boolean Bepaalt of de download plaatsvindt in de app-context of in de gebruikerscontext

De functie retourneert:

Naam Gegevenstype Lengte Beschrijving
ReturnBase64FileText Tekst Het gedownloade document in Base64

Codevoorbeeld:

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;

Bestandsversie downloaden:

De functie DownloadFileVersion downloadt een document op basis van een code.

Overload 1:

Var Naam Gegevenstype Subtype Lengte Beschrijving
Nee ParamRecordSIMDMSDocumentEntryVersion Record "SIM_DMS Document Entry Version" De versie-invoer van het Document Central-document die wordt gedownload

Overload 2:

Var Naam Gegevenstype Subtype Lengte Beschrijving
Nee ParamRecordSIMDMSDocumentEntryVersion Record "SIM_DMS Document Entry Version" De versie-invoer van het Document Central-document die wordt gedownload
Nee ParamDownloadInAppContext Boolean Definieert of de download wordt uitgevoerd in de App-context of in de gebruikerscontext

De functie retourneert:

Naam Gegevenstype Lengte Beschrijving
ReturnBase64FileText Tekst Het gedownloade document als Base64

Voorbeeldcode:

In dit voorbeeld wordt een document dat is opgeslagen bij klant 01121212 met bestandsnaam 103035.pdf gedownload in een App-context.

AL
var
    LocalRecordSIMDMSDocumentEntryVersion: Record "SIM_DMS Document Entry Version";
    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();
    if not LocalRecordSIMDMSDocumentEntryVersion.Get(LocalRecordSMIDMSModuleSetup."Repository Code", '/2024/', 'DEBITOR', 01121212, '103035.pdf',2) then
        exit;

    LocalCodeunitTempBlob.CreateOutStream(LocalOutStream);
    LocalCodeunitBase64Convert.FromBase64(LocalCodeunitSIMDMSDownloadMgt.DownloadFileVersion(LocalRecordSIMDMSDocumentEntryVersion, true), LocalOutStream);

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