Skip to content

[Extensibility Request] issue 30335: add OnBeforeRecreateSalesLine IsHandled event#9461

Open
AleksandricMarko wants to merge 1 commit into
mainfrom
ai-ext-fix/ext_issue-30335
Open

[Extensibility Request] issue 30335: add OnBeforeRecreateSalesLine IsHandled event#9461
AleksandricMarko wants to merge 1 commit into
mainfrom
ai-ext-fix/ext_issue-30335

Conversation

@AleksandricMarko

@AleksandricMarko AleksandricMarko commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

The issue author needs to conditionally replace the standard sales line recreation logic inside RecreateSalesLinesHandleSupplementTypes in table 36 "Sales Header". Under specific business conditions based on extension fields, their extension must fully take over sales line creation, which requires bypassing the standard CreateSalesLine call at the caller level. No existing extensibility point sits immediately before that call, so this PR adds a new IsHandled integration event that lets subscribers skip the standard creation and run an equivalent custom implementation.

Source issue repository: microsoft/AlAppExtensions; issue number: 30335

Changes Made

  • OnBeforeRecreateSalesLine - new IsHandled integration event published in RecreateSalesLinesHandleSupplementTypes immediately before CreateSalesLine, allowing subscribers to skip the standard sales line recreation; the same change is propagated to all country layers that have their own copy of the table.

Fixes AB#641988

… Sales Header

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AleksandricMarko AleksandricMarko added event-request SCM GitHub request for SCM area labels Jul 15, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 15, 2026
@AleksandricMarko
AleksandricMarko marked this pull request as ready for review July 17, 2026 07:44
@AleksandricMarko
AleksandricMarko requested a review from a team July 17, 2026 07:44
Comment thread src/Layers/W1/BaseApp/Sales/Document/SalesHeader.Table.al
@github-actions

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 1 · Outcome: completed

Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf

Findings by domain

Findings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).

Domain Findings Knowledge-backed Agent Inline Fallback
Events 1 1 0 1 0

Totals: 1 knowledge-backed · 0 agent findings.

Orchestrator pre-filter (2 file(s) excluded)

  • layer-disabled (knowledge) : 2 file(s)

Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

Comment thread src/Layers/W1/BaseApp/Sales/Document/SalesHeader.Table.al

@qasimikram qasimikram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event is narrowly placed around the requested CreateSalesLine call and is implemented consistently across the country-layer copies.

S1: Please add regression coverage for this new handled path. Verify that the unhandled path remains unchanged and that a subscriber can create exactly one replacement line without duplicate creation while the existing post-creation processing continues to run correctly.

auto-merge was automatically disabled July 23, 2026 16:56

Pull request was closed

ShouldCreateSalsesLine := not TempSalesLine.IsExtendedText();
OnRecreateSalesLinesHandleSupplementTypesOnAfterCalcShouldCreateSalsesLine(TempSalesLine, ShouldCreateSalsesLine, SalesLine);
if ShouldCreateSalsesLine then begin
CreateSalesLine(TempSalesLine);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟠\ High\ Severity\ —\ Events}$

The new OnBeforeRecreateSalesLine event lets any subscriber set IsHandled := true and suppress the call to CreateSalesLine entirely, but the routine keeps running as if a line had been created: it still checks SalesLine.Type, inserts into TempInteger keyed by SalesLine."Line No.", calls RecreateSalesLinesFillItemChargeAssignment, and raises OnRecreateSalesLinesHandleSupplementTypesOnAfterCreateSalesLine with a SalesLine that is stale (left over from a previous TempSalesLine iteration) rather than reflecting the current TempSalesLine. That leaves TempSalesLine's data silently dropped and downstream logic associated with the wrong line, which is exactly the kind of system inconsistency this guidance warns against. Scope the override to a safe, self-contained computation (or expose an OnAfter... event for adjustments) and run CreateSalesLine unconditionally, rather than making the insert itself skippable.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.15.4

/// <param name="TempSalesLine">The temporary sales line used as source.</param>
/// <param name="SalesHeader">The parent sales header record.</param>
[IntegrationEvent(false, false)]
local procedure OnBeforeRecreateSalesLine(var IsHandled: Boolean; var SalesLine: Record "Sales Line"; var TempSalesLine: Record "Sales Line" temporary; var SalesHeader: Record "Sales Header")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Events}$

OnBeforeRecreateSalesLine is a near-duplicate of the existing OnBeforeCreateSalesLine event: CreateSalesLine already raises OnBeforeCreateSalesLine(TempSalesLine, IsHandled, Rec, SalesLine) at its very top with 'if IsHandled then exit;', exposing the identical override (skip creating the line) with the identical data (TempSalesLine, Rec, SalesLine). A subscriber that wants to replace line creation from this call path can already do so by subscribing to OnBeforeCreateSalesLine; the new event adds a second seam for the same decision instead of reusing the one that already exists, which will leave subscribers unsure which event to pick.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.15.4

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

Labels

event-request SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants