Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ codeunit 6188 "E-Document Emailing"

var
GlobalTempBlobList: Codeunit "Temp Blob List";
GlobalExtensionList: List of [Text];
EDocumentAttachmentNameTok: Label '%1 %2', Locked = true, Comment = '%1 = Attachment name, %2 = File format';
XMLFileTypeTok: Label '.xml', Locked = true;
PDFFileTypeTok: Label '.pdf', Locked = true;
ZipFileTypeTok: Label '.zip', Locked = true;
FileNoTok: Label '_%1', Locked = true;
Expand Down Expand Up @@ -56,7 +56,7 @@ codeunit 6188 "E-Document Emailing"
SourceRelationTypes: List of [Integer];
SendToEmailAddress: Text[250];
AttachmentFileName: Text[250];
AttachmentFileExtension: Text[4];
AttachmentFileExtension: Text;
begin
TypeHelper.CopyRecVariantToRecRef(RecordVariant, SourceReference);
CreateSourceLists(ToCust, SourceReference, SourceTableIDs, SourceIDs, SourceRelationTypes);
Expand Down Expand Up @@ -87,9 +87,10 @@ codeunit 6188 "E-Document Emailing"
);
end;

procedure SetAttachments(Attachments: Codeunit "Temp Blob List")
procedure SetAttachments(Attachments: Codeunit "Temp Blob List"; ExtensionList: List of [Text])
begin
GlobalTempBlobList := Attachments;
GlobalExtensionList := ExtensionList;
end;

local procedure CreateSourceLists(ToCust: Code[20]; var SourceReference: RecordRef; var SourceTableIDs: List of [Integer]; var SourceIDs: List of [Guid]; var SourceRelationTypes: List of [Integer])
Expand Down Expand Up @@ -120,12 +121,12 @@ codeunit 6188 "E-Document Emailing"
DataCompression.CreateZipArchive();
if TempBlobList.Count() = 1 then begin
TempBlobList.Get(1, TempBlob);
DataCompression.AddEntry(TempBlob.CreateInStream(), AttachmentFileName + XMLFileTypeTok);
DataCompression.AddEntry(TempBlob.CreateInStream(), AttachmentFileName + GlobalExtensionList.Get(1));
end else
for i := 1 to TempBlobList.Count() do begin
TempBlobList.Get(i, TempBlob);
FileNo := StrSubstNo(FileNoTok, i);
DataCompression.AddEntry(TempBlob.CreateInStream(), AttachmentFileName + FileNo + XMLFileTypeTok);
DataCompression.AddEntry(TempBlob.CreateInStream(), AttachmentFileName + FileNo + GlobalExtensionList.Get(i));
end;
end;

Expand All @@ -147,7 +148,7 @@ codeunit 6188 "E-Document Emailing"
DocName: Text[150];
ToCust: Code[20];
var AttachmentFileName: Text[250];
var AttachmentFileExtension: Text[4]): Codeunit "Temp Blob"
var AttachmentFileExtension: Text): Codeunit "Temp Blob"
var
DataCompression: Codeunit "Data Compression";
TempBlob: Codeunit "Temp Blob";
Expand All @@ -159,7 +160,7 @@ codeunit 6188 "E-Document Emailing"
if (GlobalTempBlobList.Count() = 1) and (DocumentSendingProfile."E-Mail Attachment" = Enum::"Document Sending Profile Attachment Type"::"E-Document")
then begin
GlobalTempBlobList.Get(1, TempBlob);
AttachmentFileExtension := XMLFileTypeTok;
AttachmentFileExtension := GlobalExtensionList.Get(1);
end else begin
CreateZipArchiveWithEDocAttachments(DataCompression, GlobalTempBlobList, AttachmentFileName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ codeunit 6108 "E-Document Processing"
TempBlobList: Codeunit "Temp Blob List";
TypeHelper: Codeunit "Type Helper";
SourceReference: RecordRef;
ExtensionList: List of [Text];
begin
// Email if attachment is E-Document or PDF & E-Document
TypeHelper.CopyRecVariantToRecRef(RecordVariant, SourceReference);
Expand All @@ -184,11 +185,13 @@ codeunit 6108 "E-Document Processing"
if EDocumentService.FindSet() then
repeat
Clear(TempBlob);
if EDocumentLog.GetDocumentBlobFromLog(EDocument, EDocumentService, TempBlob, Enum::"E-Document Service Status"::Exported) then
if EDocumentLog.GetDocumentBlobFromLog(EDocument, EDocumentService, TempBlob, Enum::"E-Document Service Status"::Exported) then begin
TempBlobList.Add(TempBlob);
ExtensionList.Add(EDocumentService.GetDefaultFileExtension());
end;
until EDocumentService.Next() = 0;

EDocumentEmailing.SetAttachments(TempBlobList);
EDocumentEmailing.SetAttachments(TempBlobList, ExtensionList);
EDocumentEmailing.SendEDocumentEmail(DocumentSendingProfile, ReportUsage, RecordVariant, DocNo, DocName, ToCust, ShowDialog);
end;

Expand Down
22 changes: 22 additions & 0 deletions src/Apps/W1/EDocument/App/src/Service/EDocumentService.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ table 6103 "E-Document Service"
#endif
end;

/// <summary>
/// Gets the default file extension for the e-document service.
/// </summary>
/// <returns>The default file extension (e.g., '.xml'). Can be overridden via OnAfterGetDefaultFileExtension event.</returns>
procedure GetDefaultFileExtension() FileExtension: Text
var
XMLFileTypeTok: Label '.xml', Locked = true;
begin
FileExtension := XMLFileTypeTok;
OnAfterGetDefaultFileExtension(Rec, FileExtension);
end;

/// <summary>
/// Integration event that allows subscribers to override the default file extension for the e-document service.
/// </summary>
/// <param name="EDocumentService">The E-Document Service record.</param>
/// <param name="FileExtension">The file extension to be used. By default, it is set to '.xml'.</param>
[IntegrationEvent(false, false)]
local procedure OnAfterGetDefaultFileExtension(EDocumentService: Record "E-Document Service"; var FileExtension: Text)
begin
end;

var
EDocumentBackgroundJobs: Codeunit "E-Document Background Jobs";
AzureDocumentIntelligenceTok: Label 'MSEOCADI', Locked = true;
Expand Down