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.

[Event Request] codeunit 80 "Sales-Post" - OnBeforeUpdateSalesOrderLineIfExist #30428

Closed

Description

Why do you need this change?

Hi Microsoft AL Dev Team,

We would like to request a new integration event to allow skipping the standard sales order line update logic when posting a Sales Return Order from the Sales-Post codeunit.

Currently, the UpdateSalesOrderLineIfExist function runs during the posting process. In our scenario, this is causing unexpected behaviour when a return order is applied to a sales order with prepayments, as the prepayment amounts are updated back to the open sales order.

We would like to handle this process with custom logic in our app, but there is currently no extensibility point available to bypass this behaviour.

Other considerations

  • Execution frequency / performance impact: Minimal. This would only apply when posting Sales Return Orders that are applied to sales orders with prepayments.
  • Sensitive data exposure assessment: Not applicable.
  • Multiple-subscriber conflict considerations: Minimal. The event would primarily be used by extensions that need to replace the standard update logic.

Describe the request

We would like the new event at the start of the UpdateSalesOrderLineIfExist function in codeunit 80 "Sales-Post" with ability to skip the function with a IsHandled boolean.

    [IntegrationEvent(false, false)]
    local procedure OnBeforeUpdateSalesOrderLineIfExist(DocumentNo: Code[20]; var IsHandled: Boolean)
    begin
    end;

Specific location within the codeunit:

Image

Internal work item: AB#648505

Activity

  1. added
    missing-infoThe issue misses information that prevents it from completion.
    on Aug 21, 2026
  2. github-actions commented on Aug 21, 2026

    @github-actions
    Contributor

    Hi Tuan Nguyen (@tuan-nguyen-fenwick),

    Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.

    📚 Extensibility Guidelines

    Missing Information:

    • alternatives_evaluated: Please explain which existing events or extensibility patterns you evaluated in the current Sales-Post extensibility surface, what was tried or reviewed, and why those options are insufficient for this scenario instead of introducing a new IsHandled event.

    Please update the issue with the missing details. We'll automatically re-analyze once updated.

    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.

  3. tuan-nguyen-fenwick commented on Aug 28, 2026

    @tuan-nguyen-fenwick
    ContributorAuthor
    • alternatives_evaluated: We have evaluated other option but there's no other event to bypass this function. This occurs at the very end in the Sales-Post codeunit and affects open sales prepayment orders.
  4. added
    missing-infoThe issue misses information that prevents it from completion.
    and removed
    missing-infoThe issue misses information that prevents it from completion.
    on Aug 28, 2026
  5. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    Hi Tuan Nguyen (@tuan-nguyen-fenwick),

    Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.

    📚 Extensibility Guidelines

    Missing Information:

    • alternatives_evaluated: Please explain why the existing event OnBeforeUpdateSalesOrderLinesFromCreditMemo(var SalesInvoiceLine; var SalesCrMemoLine; var IsHandled) in the Correct Posted Sales Invoice flow is insufficient for your return-order/prepayment scenario.
    • custom_logic_consistency: Please confirm that if UpdateSalesOrderLineIfExist is skipped, your custom logic will preserve the required downstream sales order line update/modify consistency for the open sales order.

    Please update the issue with the missing details. We'll automatically re-analyze once updated.

    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.

  6. tuan-nguyen-fenwick commented on Sep 1, 2026

    @tuan-nguyen-fenwick
    ContributorAuthor
    • alternatives_evaluated: The existing event OnBeforeUpdateSalesOrderLinesFromCreditMemo(var SalesInvoiceLine; var SalesCrMemoLine; var IsHandled) is in an internal function that could be called else where within the base application. More specifically, it doesn't know the context that it's called from a return order posting. And therefore, we want an event within the Sales-Post codeunit itself to handle during posting of return orders with prepayments.
    • custom_logic_consistency: Yes, we will consider this.
  7. added
    SCMGitHub request for SCM area
    event-requestRequest for adding an event
    and removed
    missing-infoThe issue misses information that prevents it from completion.
    on Sep 1, 2026
  8. github-actions commented on Sep 1, 2026

    @github-actions
    Contributor

    ✅ Analysis complete - ready for further processing


    Implementation:

    Add a new OnBeforeUpdateSalesOrderLineIfExist(DocumentNo: Code[20]; var IsHandled: Boolean) integration event at the start of UpdateSalesOrderLineIfExist in codeunit 80 Sales-Post so extensions can skip the standard sales order line update logic.

    Location in UpdateSalesOrderLineIfExist procedure:

    local procedure UpdateSalesOrderLineIfExist(DocumentNo: Code[20])
    var
        SalesCreditMemoHeader: Record "Sales Cr.Memo Header";
        CorrectPostedSalesInvoice: Codeunit "Correct Posted Sales Invoice";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeUpdateSalesOrderLineIfExist(DocumentNo, IsHandled);
        if IsHandled then
            exit;
    
        SalesCreditMemoHeader.SetLoadFields("Return Order No.", "No.");
        SalesCreditMemoHeader.SetRange("Return Order No.", DocumentNo);
        if SalesCreditMemoHeader.FindFirst() then
            CorrectPostedSalesInvoice.UpdateSalesOrderLineIfExist(SalesCreditMemoHeader."No.");
    end;

    Event Publisher (add at the end of the codeunit with other events):

    [IntegrationEvent(false, false)]
    local procedure OnBeforeUpdateSalesOrderLineIfExist(DocumentNo: Code[20]; var IsHandled: Boolean)
    begin
    end;

    File: SalesPost.Codeunit.al

    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.

  9. JesperSchulz commented on Sep 3, 2026

    @JesperSchulz
    Contributor

    The requested change has been implemented in microsoft/BCApps#10901, and the corresponding Azure Boards work item 648505 is resolved as fixed. Closing this issue as completed.

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