[Event Extensibility Request] Table 61 "Electronic Document Format" - OnSendElectronicallyOnAfterRecRefGetTable #27951
Open
Description
Describe the request
Hi, would it be possible to extend an event OnSendElectronicallyOnAfterRecRefGetTable event on table 61 (Electronic Document Format), like this:
procedure SendElectronically(var TempBlob: Codeunit "Temp Blob"; var ClientFileName: Text[250]; DocumentVariant: Variant; ElectronicFormat: Code[20])
var
RecordExportBuffer: Record "Record Export Buffer";
TempErrorMessage: Record "Error Message" temporary;
ErrorMessage: Record "Error Message";
EntryTempBlob: Codeunit "Temp Blob";
RecRef: RecordRef;
EntryFileInStream: InStream;
ZipFileOutStream: OutStream;
DocumentUsage: Enum "Electronic Document Format Usage";
StartID: Integer;
EndID: Integer;
IsMissingFileContent: Boolean;
begin
GetDocumentFormatUsage(DocumentUsage, DocumentVariant);
if not Get(ElectronicFormat, DocumentUsage) then begin
Usage := DocumentUsage;
Error(NonExistingDocumentFormatErr, ElectronicFormat, Format(Usage));
end;
RecRef.GetTable(DocumentVariant);
// old event begin
OnSendElectronicallyOnAfterRecRefGetTable(RecRef);
// old event end
// new event begin
OnSendElectronicallyOnAfterRecRefGetTable(Rec, RecRef);
// new event end
StartID := 0;
RecordExportBuffer.LockTable();
if RecRef.FindSet() then
repeat
Clear(RecordExportBuffer);
RecordExportBuffer.RecordID := RecRef.RecordId;
RecordExportBuffer.ClientFileName :=
GetAttachmentFileName(RecRef, GetDocumentNo(RecRef), GetDocumentType(RecRef), 'xml');
RecordExportBuffer.ZipFileName :=
GetAttachmentFileName(RecRef, GetDocumentNo(RecRef), GetDocumentType(RecRef), 'zip');
OnSendElectronicallyOnBeforeRecordExportBufferInsert(RecordExportBuffer, RecRef);
RecordExportBuffer.Insert(true);
if StartID = 0 then
StartID := RecordExportBuffer.ID;
EndID := RecordExportBuffer.ID;
until RecRef.Next() = 0;
RecordExportBuffer.SetRange(ID, StartID, EndID);
if RecordExportBuffer.FindSet() then
repeat
ErrorMessage.SetContext(RecordExportBuffer);
ErrorMessage.ClearLog();
CODEUNIT.Run("Codeunit ID", RecordExportBuffer);
TempErrorMessage.CopyFromContext(RecordExportBuffer);
ErrorMessage.ClearLog(); // Clean up
if not RecordExportBuffer."File Content".HasValue() then
IsMissingFileContent := true;
until RecordExportBuffer.Next() = 0;
// Display errors in case anything went wrong.
TempErrorMessage.ShowErrorMessages(true);
if IsMissingFileContent then
Error(ElectronicDocumentNotCreatedErr);
if RecordExportBuffer.Count > 1 then begin
TempBlob.CreateOutStream(ZipFileOutStream);
DataCompression.CreateZipArchive();
ClientFileName := CopyStr(RecordExportBuffer.ZipFileName, 1, 250);
RecordExportBuffer.FindSet();
repeat
RecordExportBuffer.GetFileContent(EntryTempBlob);
EntryTempBlob.CreateInStream(EntryFileInStream);
DataCompression.AddEntry(EntryFileInStream, RecordExportBuffer.ClientFileName);
until RecordExportBuffer.Next() = 0;
DataCompression.SaveZipArchive(ZipFileOutStream);
DataCompression.CloseZipArchive();
end else
if RecordExportBuffer.FindFirst() then begin
RecordExportBuffer.GetFileContent(TempBlob);
ClientFileName := RecordExportBuffer.ClientFileName;
end;
OnSendElectronicallyOnBeforeDeleteAll(RecordExportBuffer, ClientFileName, DocumentVariant);
RecordExportBuffer.DeleteAll();
end;
// old event begin
[IntegrationEvent(false, false)]
local procedure OnSendElectronicallyOnAfterRecRefGetTable(var RecRef: RecordRef)
begin
end;
// old event end
// new event begin
[IntegrationEvent(false, false)]
local procedure OnSendElectronicallyOnAfterRecRefGetTable(Rec: Record "Electronic Document Format"; var RecRef: RecordRef)
begin
end;
// new event end
Thanks!
Additional context
There is a need to adjust the Electronic Document Format table with some extra information and in Send Electronically there is a need to know which exactly record is run. Currently - it's not available.
Internal work item: AB#562695