[Additional Parameters] CU 80 Sales Post OnAfterInsertPostedHeaders
Describe the request
In Codeunit 80, please add new parameters on OnAfterInsertPostedHeaders event: var GenJnlLineDocType: enum "Gen. Journal Document Type"; var GenJnlLineDocNo: Code[20]; var GenJnlLineExtDocNo: Code[35]
Actual Code:
IsHandled := false;
OnInsertPostedHeadersOnBeforeInsertInvoiceHeader(SalesHeader, IsHandled, SalesInvHeader, GenJnlLineDocType, GenJnlLineDocNo, GenJnlLineExtDocNo, InvoicePostingInterface);
if not IsHandled then
// Insert invoice header or credit memo header
if SalesHeader.Invoice then begin
ShouldInsertInvoiceHeader := SalesHeader."Document Type" in [SalesHeader."Document Type"::Order, SalesHeader."Document Type"::Invoice];
OnInsertPostedHeadersOnAfterCalcShouldInsertInvoiceHeader(SalesHeader, ShouldInsertInvoiceHeader);
if ShouldInsertInvoiceHeader then begin
InsertInvoiceHeader(SalesHeader, SalesInvHeader);
GenJnlLineDocType := GenJnlLine."Document Type"::Invoice;
GenJnlLineDocNo := SalesInvHeader."No.";
GenJnlLineExtDocNo := SalesInvHeader."External Document No.";
OnInsertPostedHeadersOnAfterInsertInvoiceHeader(SalesHeader, SalesInvHeader);
end else begin // Credit Memo
InsertCrMemoHeader(SalesHeader, SalesCrMemoHeader);
GenJnlLineDocType := GenJnlLine."Document Type"::"Credit Memo";
GenJnlLineDocNo := SalesCrMemoHeader."No.";
GenJnlLineExtDocNo := SalesCrMemoHeader."External Document No.";
OnInsertPostedHeadersOnAfterInsertCrMemoHeader(SalesHeader, SalesCrMemoHeader);
end;
#if not CLEAN23
if not UseLegacyInvoicePosting() then begin
#endif
GetInvoicePostingParameters();
InvoicePostingInterface.SetParameters(InvoicePostingParameters);
#if not CLEAN23
end;
#endif
end;
OnAfterInsertPostedHeaders(SalesHeader, SalesShptHeader, SalesInvHeader, SalesCrMemoHeader, ReturnRcptHeader);
New Code
OnAfterInsertPostedHeaders(SalesHeader, SalesShptHeader, SalesInvHeader, SalesCrMemoHeader, ReturnRcptHeader, GenJnlLineDocType, GenJnlLineDocNo, GenJnlLineExtDocNo);
[IntegrationEvent(false, false)]
local procedure OnAfterInsertPostedHeaders(var SalesHeader: Record "Sales Header"; var SalesShipmentHeader: Record "Sales Shipment Header"; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesCrMemoHdr: Record "Sales Cr.Memo Header"; var ReceiptHeader: Record "Return Receipt Header"; var GenJnlLineDocType: Enum "Gen. Journal Document Type"; var GenJnlLineDocNo: Code[20]; var GenJnlLineExtDocNo: Code[35])
begin
end;
Additional context
We have these parameters on OnInsertPostedHeadersOnBeforeInsertInvoiceHeader() and we used it to set the IsHandled variable equal to true, and skip the code below. Now, we have installed an additional extension created by another MS partner, and this extension is used the code in InsertInvoiceHeader() and InsertCrMemoHeader() procedures
We can't set IsHandled := true, we set IsHandled := false on OnInsertPostedHeadersOnBeforeInsertInvoiceHeader() the code below is running
We should set the global variable GenJnlLineDocType in OnAfterInsertPostedHeaders() (or in OnInsertPostedHeadersOnAfterInsertInvoiceHeader() and in OnInsertPostedHeadersOnAfterInsertCrMemoHeader()) Internal work item: AB#559837
Hello @jacmax We will add the extra parameters
Availability update: We will publish a fix for this issue in the next update for release 26.
Build ID to track: 32403.
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.
Build ID: 32270.