Skip to content

[Event Request] Codeunit 1173 "Document Attachment Mgmt" #29461

@kalozoya-orisha

Description

@kalozoya-orisha

Why do you need this change?

We use Azure Blob Storage to store the files in the "Document Attachment" table instead of the database (Media field). To maintain consistency between the recors and the physical path (blob path), we leverega existing events during the copy processes:

  • OnCopyAttachmentsForPostedDocsLinesOnAfterSetToTableID
  • OnCopyAttachmentsOnAfterSetToDocumentFilters
  • OnCopyAttachmentsForPostedDocsOnBeforeToDocumentAttachmentInsert

In those events, we can download the original blob and republish it to ABS, generating a new path that incorporates the new "No." value. However, in the MoveAttachmentsWithinSameRecordType procedure (whhen moving/rename attachments within the same record type by changing the "No."), there is no event before the Insert that allows this. Furthermore, it deletes the original record, causing the blob in ABS to be deleted as well, and the new record continues to reference the same blob path.

Describe the request

Proposed event:
Name: OnMoveAttachmentsWithinSameRecordTypeOnBeforeInsert

Parameters:

  • var DocumentAttachmentToCreate: Record "Document Attachment"
  • MoveToRecRef: RecordRef
  • MoveToRecNo: Code[20]

Suggested insertion (just before the Insert)

// ...existing code...
repeat
    Clear(DocumentAttachmentToCreate);
    DocumentAttachmentToCreate.Init();
    DocumentAttachmentToCreate.TransferFields(DocumentAttachmentFound);
    DocumentAttachmentToCreate.Validate("No.", MoveToRecNo);
    OnMoveAttachmentsWithinSameRecordTypeOnBeforeInsert(DocumentAttachmentToCreate, MoveToRecRef, MoveToRecNo);
    DocumentAttachmentToCreate.Insert(true);
until DocumentAttachmentFound.Next() = 0;
// ...existing code...

IntegrationEvent declaration:

[IntegrationEvent(false, false)]
local procedure OnMoveAttachmentsWithinSameRecordTypeOnBeforeInsert(var DocumentAttachmentToCreate: Record "Document Attachment"; MoveToRecRef: RecordRef; MoveToRecNo: Code[20])
begin
end;

Without it, a function gap remains, forcing subsecquent solutions that are less efficient and more fragile.

Thank you very much for your time.
Internal work item: AB#614927

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions