Ga naar inhoud

Broncode-gebaseerde opslag van documenten

Document Central kan worden uitgebreid met code waarmee documenten vanuit een BLOB via code naar Document Central kunnen worden geüpload. Hierdoor is het mogelijk om automatisch een Document Central-barcode te genereren en toe te voegen wanneer een rapport wordt afgedrukt of een document wordt geboekt of geconverteerd.

Aan de volgende vereisten moet worden voldaan:

  • De Document Central-module moet gelicentieerd zijn.
  • CORE moet beschikbaar zijn in de extensie als referentie.
  • Document Central moet aanwezig zijn in de extensie als referentie.

Inkomende documenten toevoegen

Voor het toevoegen van documenten aan de inkomende lijst kunnen 2 functies in "SIM_DI Upload Mgt" worden gebruikt: AddInboundDocumentFromExternal & AddInboundDocumentFromSilentUpload.

AddInboundDocumentFromSilentUpload

Var Naam Gegevenstype Subtype Lengte Beschrijving
Nee Filename Text De originele bestandsnaam van het document
Nee Base64File Text Het bestand als base64-tekenreeks
Nee InboundListCode Code 20 Code van de inkomende lijst
Nee StatusCheckText Text Statuscontrole
Nee Recordref RecordRef De recordreferentie waarnaar het document moet worden geüpload
Nee ParamContentTypeText Text De tekst van het inhoudstype
Nee InfoTagText Text Infotag
Nee EnumSIMDIInboundDocSource Enum "SIM_DI Inbound Doc Source" De bronstatus
Nee OriginText Text Oorsprongtekst
Show example code
AL
var
    SalesHeader: Record "Sales Header";
    UploadMgt: Codeunit "SIM_DI Upload Mgt";
    FileManagement: Codeunit "File Management";
    Base64Convert: Codeunit "Base64 Convert";
    TempBlob: Codeunit "Temp Blob";
    RecordReference: RecordRef;
    InStr: InStream;
    Filename: Text;
    Base64File: Text;
    AllFilesFilterTxt: Label '*.*', Locked = true;
    AllFilesDescriptionTxt: Label 'All Files (*.*)|*.*', Comment = '{Split=r''\|''}{Locked=s''1''}';
    DialogCaptionTxt: Label 'Choose Upload File';
begin
    Filename := FileManagement.BLOBImportWithFilter(TempBlob, DialogCaptionTxt, '', AllFilesDescriptionTxt, AllFilesFilterTxt);
    Filename := FileManagement.GetFileName(Filename);
    if Filename = '' then exit;

    Clear(InStr);
    TempBlob.CreateInStream(InStr);
    Base64File := Base64Convert.ToBase64(InStr);

    SalesHeader.Reset();
    SalesHeader.FindFirst();
    RecordReference.GetTable(SalesHeader);

    UploadMgt.AddInboundDocumentFromSilentUpload(
        Filename,                                       // ParamFileNameText
        Base64File,                                     // ParamBase64Text
        'INBOUND-LIST',                                 // ParamInboundListCode
        '',                                             // ParamStatusCheckText
        RecordReference,                                // ParamRecordRef
        'INVOICE',                                      // ParamContentTypeText
        '',                                             // ParamInfoTagText
        Enum::"SIM_DI Inbound Doc Source"::Upload,      // ParamEnumSIMDIInboundDocSource
        UserId()                                        // ParamOriginText
    );
end;

AddInboundDocumentFromExternal

Var Naam Gegevenstype Subtype Lengte Beschrijving
Nee ParamFileNameText Text De originele bestandsnaam van het document
Nee ParamBase64Text Text Het bestand als base64-tekenreeks
Nee ParamInboundListCode Code 20 Code van de inkomende lijst
Nee ParamMetadataJsonText Text Metadata als JSON-tekenreeks
Nee ParamRecordId RecordId Het record-id waaraan het document moet worden gekoppeld
Nee ParamContentTypeText Text De tekst van het inhoudstype
Nee ParamDocumentLibraryCode Code 20 Code van de documentbibliotheek
Nee ParamInfoTagText Text Infotag
Nee ParamEnumSIMDIInboundDocSource Enum "SIM_DI Inbound Doc Source" De bron van het document
Show example code
AL
var
    SalesHeader: Record "Purchase Header";
    UploadMgt: Codeunit "SIM_DI Upload Mgt";
    FileManagement: Codeunit "File Management";
    Base64Convert: Codeunit "Base64 Convert";
    TempBlob: Codeunit "Temp Blob";
    InStr: InStream;
    Filename: Text;
    Base64File: Text;
    MetadataJsonText: Text;
    MetadataJsonObject: JsonObject;
    AllFilesFilterTxt: Label '*.*', Locked = true;
    AllFilesDescriptionTxt: Label 'All Files (*.*)|*.*', Comment = '{Split=r''\|''}{Locked=s''1''}';
    DialogCaptionTxt: Label 'Choose Upload File';
begin
    Filename := FileManagement.BLOBImportWithFilter(TempBlob, DialogCaptionTxt, '', AllFilesDescriptionTxt, AllFilesFilterTxt);
    Filename := FileManagement.GetFileName(Filename);
    if Filename = '' then exit;

    Clear(InStr);
    TempBlob.CreateInStream(InStr);
    Base64File := Base64Convert.ToBase64(InStr);

    MetadataJsonObject.Add('dmssalesinvoiceno', 'PI-10000');
    MetadataJsonObject.Add('dmscustomerno', 'Adatum Corporation');
    MetadataJsonText := Format(MetadataJsonObject); // Format or other Extraction Methods

    SalesHeader.Get(SalesHeader."Document Type"::Invoice, 'PI-10000');

    UploadMgt.AddInboundDocumentFromExternal(
        Filename,                                       // ParamFileNameText
        Base64File,                                     // ParamBase64Text
        'INBOUND-LIST',                                 // ParamInboundListCode
        MetadataJsonText,                               // ParamMetadataJsonText - Can also be an Empty Text
        SalesHeader.RecordId(),                         // ParamRecordId - Necessary if the Assignment Method is Record Id
        'INVOICE',                                      // ParamContentTypeText
        'DOC-LIB-SALESINV',                             // ParamDocumentLibraryCode
        '',                                             // ParamInfoTagText
        Enum::"SIM_DI Inbound Doc Source"::Upload       // ParamEnumSIMDIInboundDocSource
    );
end;