Skip to main content

Alternative use of the SQUEEZE attachments

ImThe Folgendenfollowing wirdbriefly kurzexplains erläutert,how wiethe dieattachments durchdownloaded by SQUEEZE for BC heruntergeladenencan Anhängebe fürused einfor Szenarioa verwendetscenario werdenthat können,differs dasfrom vonthe derintended vorgesehenen Verwendung abweicht. use.

NachAfter dercreating Erstellungthe despurchase Einkaufsbelegesdocument ausfrom demthe validiertenvalidated SQUEEZE Belegdocument, habenyou Siehave diethe Möglichkeit,option dieof Anhängeaccessing abzugreifenthe attachments (sofern dieseassuming imthey Vorfeldhave heruntergeladenbeen wurden)downloaded in advance).

    // Set IsHandled to true and implement your code
    // Do not forget to deactivate "Transfer attachments to target document" in the Document Class Setup
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"DXP Document Mgt.", 'OnBeforeTransferCoreAttachmentsToStandardDocument', '', false, false)]
    local procedure DXPDocMgtOnBeforeTransferCoreAttachmentsToStandardDocument(Document: Record "DXP Document"; var IsHandled: Boolean)
    begin
    	IsHandled := true;
        HandleCoreAttachmentsAccordingToYourNeeds(Document, IsHandled);
    end;

    procedure HandleCoreAttachmentsAccordingToYourNeeds(Document: Record "DXP Document"; var IsHandled: Boolean)
    var
        CoreAttachments: Record "DXP Document Attachment";
        InStr: InStream;
    begin
        CoreAttachments.SetRange("Document No.", Document."No.");
        CoreAttachments.IsEmpty() then
       		exit;
        CoreAttachments.FindSet();
        repeat
            CoreAttachments.Calcfields(Attachment);
            CoreAttachments.Attachment.CreateInStream(InStr);
            // Here you can handle the file stream according to your needs
         	[...]
        until CoreAttachments.Next() = 0;
    end;