microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
774 stars 609 forks source link

[Event Request] codeunit 6108 "E-Document Processing" OnBeforeGetDocSendingProfileForDocRef #27107

Open pri-kise opened 1 month ago

pri-kise commented 1 month ago

Describe the request

Could you please add the following event and make the codeunit Public or add a new facade codeunit that we're able to subscribe to this event?

procedure GetDocSendingProfileForDocRef(var RecRef: RecordRef): Record "Document Sending Profile";
var
    SalesHeader: Record "Sales Header";
    PurchaseHeader: Record "Purchase Header";
    FinChargeMemoHeader: Record "Finance Charge Memo Header";
begin
    //+EVENT
    IsHandled := false;
    OnBeforeGetDocSendingProfileForDocRef(RecRef, DocumentSendingProfile, IsHandled);
    if IsHandled then
       exit(DocumentSendingProfile);
    //-EVENT
    case RecRef.Number of
        Database::"Sales Header", Database::"Sales Invoice Header", Database::"Sales Cr.Memo Header",
        Database::"Service Header", Database::"Service Invoice Header", Database::"Service Cr.Memo Header":
            exit(GetDocSendingProfileForCustVend(RecRef.Field(SalesHeader.FieldNo("Bill-to Customer No.")).Value, ''));

        Database::"Finance Charge Memo Header", Database::"Issued Fin. Charge Memo Header",
        Database::"Reminder Header", Database::"Issued Reminder Header":
            exit(GetDocSendingProfileForCustVend(RecRef.Field(FinChargeMemoHeader.FieldNo("Customer No.")).Value, ''));

        Database::"Purchase Header", Database::"Purch. Inv. Header", Database::"Purch. Cr. Memo Hdr.":
            exit(GetDocSendingProfileForCustVend('', RecRef.Field(PurchaseHeader.FieldNo("Pay-to Vendor No.")).Value));
    end;
end;

    [IntegrationEvent(false, false)]
    local procedure OnBeforeGetDocSendingProfileForDocRef(var SourceDocumentHeader: RecordRef; var DocumentSendingProfile: Record "Document Sending Profile"; var IsHandled: Boolean );
    begin
    end;

Additional context

We would like to use a custom Document Sending Profile for specific Records like Sales Invoice Header. Internal work item: AB#545264

Groenbech96 commented 2 days ago

My understanding: You want to be able to create and send EDocument from posted doucments?