Skip to content

[Parameter request on event] - Codeunit "Sales Post Invoice Events" #30270

Description

@exnihiloo

Why do you need this change?

We need additional parameter var JobPostLine: Codeunit "Job Post-Line" on procedure RunOnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll and event OnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll

In Codeunit 80 (Sales-Post), the posting pipeline creates job-related sales lines through the Invoice Posting Interface method PrepareJobLine, which generates a temporary record: TempSalesLineJob: Record "Sales Line" temporary;

Later in the process, the event: OnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll is raised at the correct lifecycle moment - just before the temporary invoice posting buffer is deleted.
However, this event currently does not expose the Job Post-Line codeunit, which is required to execute: JobPostLine.PostJobSalesLines(...). This prevents extensions from correctly continuing the job posting flow using the prepared temporary data.

Alternatives Evaluated

  1. Existing Events
    Reviewed events in:
    Codeunit 80 (Sales-Post)
    Invoice Posting Interface

    Limitation:
    No event exposes both:

    Prepared TempSalesLineJob
    JobPostLine instance

  2. Reconstructing TempSalesLineJob
    Attempted rebuilding from Sales Line
    Limitation:

    Logic inside PrepareJobLine is internal and complex
    High risk of inconsistencies and future breaking changes

  3. Independent Job Posting Call
    Attempted external execution of PostJobSalesLines
    Limitation:

    Required data exists only during posting pipeline
    Timing mismatch (data already disposed after event)

Performance Considerations
Event is triggered once per document posting
Adding a codeunit parameter:

Has negligible overhead
Does not introduce additional database operations

Any additional logic executes on already-prepared temporary data

Data Sensitivity
No new data structures are exposed
JobPostLine:

Does not contain sensitive data by itself
Operates within the same posting security context

Existing event already exposes sales and posting data

Benefits
Enables correct reuse of standard job posting logic
Avoids duplication of internal business logic
Improves extensibility of the sales posting pipeline
Aligns with existing extensibility patterns in Business Central

Enables correct reuse of standard job posting logic
Avoids duplication of internal business logic
Improves extensibility of the sales posting pipeline
Aligns with existing extensibility patterns in Business Central

Describe the request

Existing event :

procedure RunOnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll(var SalesHeader: Record "Sales Header"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; var InvoicePostingParameters: Record "Invoice Posting Parameters")
begin
    OnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll(SalesHeader, GenJnlPostLine, TotalSalesLine, TotalSalesLineLCY, InvoicePostingParameters);
end;

[IntegrationEvent(false, false)]
local procedure OnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll(var SalesHeader: Record "Sales Header"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; var InvoicePostingParameters: Record "Invoice Posting Parameters")
begin
end;

Modified event :

procedure RunOnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll(var SalesHeader: Record "Sales Header"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; var InvoicePostingParameters: Record "Invoice Posting Parameters"; var JobPostLine: Codeunit "Job Post-Line")
begin
    OnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll(SalesHeader, GenJnlPostLine, TotalSalesLine, TotalSalesLineLCY, InvoicePostingParameters);
end;

[IntegrationEvent(false, false)]
local procedure OnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll(var SalesHeader: Record "Sales Header"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; var InvoicePostingParameters: Record "Invoice Posting Parameters"; var JobPostLine: Codeunit "Job Post-Line")
begin
end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions