Deviating use of the SQUEEZE attachments
The following is a brief explanation of how the attachments downloaded through SQUEEZE for BC can be used for a scenario that differs from the intended use.
After creating the purchasing document from the validated SQUEEZE document, you have the option to retrieve the attachments (if they have been 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;
No Comments