Skip to content

[Event Request] codeunit 6753 "Send Reminder Event Handler" - OnAfterAttachRelatedDocument #29591

@chochi2233

Description

@chochi2233

Why do you need this change?

We want to attach the Service Invoice to the Email when the IssuedReminderHeader is Sent over the Automation.

Describe the request

Hello,
can you please add a new event OnAfterAttachRelatedDocument in procedure AttachRelatedDocumentsBeforeEmailFileInternal in Codeunit 6753 "Send Reminder Event Handler"

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", 'OnBeforeEmailItemPreparation', '', false, false)]
    local procedure AttachRelatedDocumentsBeforeEmailFileInternal(var TempEmailItem: Record "Email Item" temporary; var PostedDocNo: Code[20]; var ReportUsage: Integer)
    var
        SourceTableList: List of [Integer];
        SourceIDList: List of [Guid];
        SourceRelationTypeList: List of [Integer];
        SourceTableID: Integer;
        SourceRelationID: Integer;
        SourceID: Guid;
        AttachRelatedDocument: Boolean;
        I: Integer;
    begin
        if ReportUsage <> Enum::"Report Selection Usage"::Reminder.AsInteger() then
            exit;

        if SendRemindersSetup."Attach Invoice Documents" = SendRemindersSetup."Attach Invoice Documents"::No then
            exit;

        TempEmailItem.GetSourceDocuments(SourceTableList, SourceIDList, SourceRelationTypeList);

        for I := 1 to SourceTableList.Count() do begin
            SourceTableID := SourceTableList.Get(I);
            SourceRelationID := SourceRelationTypeList.Get(I);
            SourceID := SourceIDList.Get(I);

            if SourceTableID = Database::"Sales Invoice Header" then
                if SendRemindersSetup."Attach Invoice Documents" = SendRemindersSetup."Attach Invoice Documents"::All then
                    AttachRelatedDocument := true
                else
                    AttachRelatedDocument := IsInvoiceOverdue(PostedDocNo, SourceID);

            if AttachRelatedDocument then
                AttachDocument(TempEmailItem, SourceTableID, SourceRelationID, SourceID);
            OnAfterAttachRelatedDocument(TempEmailItem, PostedDocNo, SendRemindersSetup, SourceTableID, SourceRelationID, SourceID, ReportUsage);
        end;
    end;
    [IntegrationEvent(false, false)]
    local procedure OnAfterAttachRelatedDocument(var TempEmailItem: Record "Email Item" temporary; var PostedDocNo: Code[20]; SendRemindersSetup: Record "Send Reminders Setup"; SourceTableID: Integer; SourceRelationID: Integer; SourceID: Guid; ReportUsage: Integer)
    begin
    end;

Internal work item: AB#618288

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM 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