Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

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

Closed

Description

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;

Internal work item: AB#647451

Activity

  1. github-actions commented on Jun 16, 2026

    @github-actions
    Contributor

    Hi Companial/DeimantėJasaitytė (@exnihiloo),

    Thank you for your extensibility request. Unfortunately, this request cannot be implemented.

    Reason: Implementation would require changing the public procedure signature of RunOnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll by adding a new parameter, which is a breaking change. Because the request contains multiple linked changes, the entire request must be rejected.

    Note

    Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.

    Tip

    Not accurate? Reply with /not-accurate (optional: add a short explanation). Your feedback improves future responses.

  2. exnihiloo commented on Jun 17, 2026

    @exnihiloo
    Author

    /not-accurate hello, can engineer review this?

  3. github-actions commented on Jun 17, 2026

    @github-actions
    Contributor

    ✅ Feedback recorded
    Thanks — your /not-accurate feedback has been logged and will be reviewed.

  4. exnihiloo commented on Jun 23, 2026

    @exnihiloo
    Author

    Hello, any news regarding this one?

  5. AleksandricMarko commented on Jun 24, 2026

    @AleksandricMarko
    Contributor

    Hello Companial/DeimantėJasaitytė (@exnihiloo),

    Could you explain us a purpose, why you need "JobPostLine" in your extension

  6. exnihiloo commented on Jun 29, 2026

    @exnihiloo
    Author

    Marko Aleksandric (@AleksandricMarko)
    Hello, we need JobPostLine because we are running PostJobSalesLines on RunOnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll for our solution standard PostJobSalesLines procedure (which runs from PostLines repeat loop) will not run as we avoid using TempInvoicePostingBuffer and we are using our own custom TempPostingBuffer table, for that case we need var JobPostLine: Codeunit "Job Post-Line" since the proceudre PostJobSalesLines uses global variable TempSalesLineJob which is set by running PrepareJobLine on codeunit 815 "Sales Post Invoice" implements "Invoice Posting".

  7. exnihiloo commented on Aug 7, 2026

    @exnihiloo
    Author

    Marko Aleksandric (@AleksandricMarko)
    Good day, any decisions regarding this case?

  8. AleksandricMarko commented on Aug 7, 2026

    @AleksandricMarko
    Contributor

    Hi Companial/DeimantėJasaitytė (@exnihiloo),

    I reopened issue so we can discuss about solution,
    Adding parameter to public procedure is not possible, so we can discus just on different approaches.
    Would it be possible for you adding new event somewhere else as alternative?

  9. exnihiloo commented on Aug 10, 2026

    @exnihiloo
    Author

    Hello, Marko Aleksandric (@AleksandricMarko),

    if it's not possible to add parameter on the existing procedure and event, would it be possible to add new procedure and event which is copy of existing procedure just with additional parameter JobPostLine?

    On codeunit 815 "Sales Post Invoice" implements "Invoice Posting"

    procedure PostLines(DocumentHeaderVar: Variant; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var Window: Dialog; var TotalAmount: Decimal)
    var
      SalesHeader: Record "Sales Header";
      GenJnlLine: Record "Gen. Journal Line";
      JobSalesLine: Record "Sales Line";
      GLEntryNo: Integer;
      LineCount: Integer;
    begin
      SalesHeader := DocumentHeaderVar;
    
      SalesPostInvoiceEvents.RunOnBeforePostLines(SalesHeader, TempInvoicePostingBuffer);
    
      LineCount := 0;
      if TempInvoicePostingBuffer.Find('+') then
          repeat
              LineCount := LineCount + 1;
              if GuiAllowed() and not HideProgressWindow then
                  Window.Update(3, LineCount);
    
              TempInvoicePostingBuffer.ApplyRoundingForFinalPosting();
              PrepareGenJnlLine(SalesHeader, TempInvoicePostingBuffer, GenJnlLine);
    
              SalesPostInvoiceEvents.RunOnPostLinesOnBeforeGenJnlLinePost(
                  GenJnlLine, SalesHeader, TempInvoicePostingBuffer, GenJnlPostLine, PreviewMode, SuppressCommit);
              GLEntryNo := RunGenJnlPostLine(GenJnlLine, GenJnlPostLine);
              SalesPostInvoiceEvents.RunOnPostLinesOnAfterGenJnlLinePost(
                  GenJnlLine, SalesHeader, TempInvoicePostingBuffer, GenJnlPostLine, PreviewMode, SuppressCommit, GLEntryNo);
    
              if (TempInvoicePostingBuffer."Job No." <> '') and
                 (TempInvoicePostingBuffer.Type = TempInvoicePostingBuffer.Type::"G/L Account")
              then begin
                  SetJobLineFilters(JobSalesLine, TempInvoicePostingBuffer);
                  JobPostLine.PostJobSalesLines(JobSalesLine.GetView(), GLEntryNo);
                  SalesPostInvoiceEvents.RunOnPostLinesOnAfterPostJobSalesLines(
                    SalesHeader, TempInvoicePostingBuffer, TotalSalesLine, TotalSalesLineLCY, GLEntryNo, InvoicePostingParameters);
              end;
          until TempInvoicePostingBuffer.Next(-1) = 0;
    
      TempInvoicePostingBuffer.CalcSums(Amount);
      TotalAmount := -TempInvoicePostingBuffer.Amount;
    
      SalesPostInvoiceEvents.RunOnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll(
          SalesHeader, GenJnlPostLine, TotalSalesLine, TotalSalesLineLCY, InvoicePostingParameters);
    
      SalesPostInvoiceEvents.RunOnPostLinesOnBeforeTempInvoicePostingBufferDeleteAll2(
          SalesHeader, GenJnlPostLine, TotalSalesLine, TotalSalesLineLCY, InvoicePostingParameters, JobPostLine); //New 
      TempInvoicePostingBuffer.DeleteAll();
    end;

    we need this procedure in the exact place, before TempInvoicePostingBuffer deletion

  10. AleksandricMarko commented on Aug 10, 2026

    @AleksandricMarko
    Contributor

    Hi Companial/DeimantėJasaitytė (@exnihiloo),

    Would it be possible to add new event before

    TempInvoicePostingBuffer.CalcSums(Amount);
    TotalAmount := -TempInvoicePostingBuffer.Amount;

    Just to avoid having 2 events next to each other (we can include skip pattern for these 2 lines if it is needed)?

  11. exnihiloo commented on Aug 13, 2026

    @exnihiloo
    Author

    Hello, Marko Aleksandric (@AleksandricMarko),

    yes that would be great! Will you keep the same parameters plus adding JobPostLine?

  12. exnihiloo commented on Aug 21, 2026

    @exnihiloo
    Author

    Hello, Marko Aleksandric (@AleksandricMarko),

    any information when this request will be added?

  13. added
    event-requestRequest for adding an event
    SCMGitHub request for SCM area
    ext-ready-to-implementReviewed and ready to implement and create PR
    and removed
    missing-infoThe issue misses information that prevents it from completion.
    on Aug 21, 2026
  14. AleksandricMarko commented on Sep 18, 2026

    @AleksandricMarko
    Contributor

    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.
    PR: microsoft/BCApps#10513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventext-ready-to-implementReviewed and ready to implement and create PR

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions