Skip to content

(Bug 635844): [Subcontracting] SubcTransferLine "Work Center No." OnValidate overwrites Gen. Prod. Posting Group — dead code that is potentially dangerous#8283

Open
alexei-dobriansky wants to merge 1 commit into
mainfrom
bugs/635844-Subcon_OverwritingGetProdPostingGroup
Open

(Bug 635844): [Subcontracting] SubcTransferLine "Work Center No." OnValidate overwrites Gen. Prod. Posting Group — dead code that is potentially dangerous#8283
alexei-dobriansky wants to merge 1 commit into
mainfrom
bugs/635844-Subcon_OverwritingGetProdPostingGroup

Conversation

@alexei-dobriansky
Copy link
Copy Markdown
Contributor

@alexei-dobriansky alexei-dobriansky commented May 22, 2026

Summary

Removes a dormant OnValidate trigger on "Subc. Work Center No." (field 99001537) in SubcTransferLine.TableExt.al that would silently overwrite the transfer line's "Gen. Prod. Posting Group" with the Work Center's posting group if ever invoked via Validate(...).

Problem

The trigger:

trigger OnValidate()
var
    WorkCenter: Record "Work Center";
begin
    if "Subc. Work Center No." = '' then
        exit;
    WorkCenter.Get("Subc. Work Center No.");
    "Gen. Prod. Posting Group" := WorkCenter."Gen. Prod. Posting Group";
end;
  • Is dead code today — every caller in the codebase assigns the field with :=, never Validate(...), and the page field is Editable = false/Visible = false.
  • Is a latent footgun — on a standard transfer flow "Gen. Prod. Posting Group" is correctly populated from the Item card via Validate("Item No.") in BaseApp's TransferLine. The first caller who writes Validate("Subc. Work Center No.", ...) would silently replace the Item's posting group with the Work Center's, producing wrong G/L entries on transfer posting with no error.

"Subc. Work Center No." on the transfer line is purely informational/traceability — it is propagated as-is into posted shipment/receipt/direct-transfer lines and into SubcontractorWIPLedgerEntry, but never participates in calculations, filtering on transfer lines, or G/L posting logic.

Fix

Delete the body of the OnValidate trigger. The field definition (caption, table relation, tooltip) is unchanged.

Verification

  • Searched all references to "Subc. Work Center No." across App/ and Test/: every write uses :=; no Validate("Subc. Work Center No.", ...) exists anywhere.
  • Page field on SubcTransOrderSub.PageExt.al is Editable = false and Visible = false — no UI trigger path.
  • No existing test exercised the trigger, so no test regressions are expected.

Risk

Minimal. The trigger never executes today, so behavior on existing flows is unchanged. The change eliminates a future correctness risk for G/L posting.

Fixes AB#635844

@alexei-dobriansky alexei-dobriansky self-assigned this May 22, 2026
@alexei-dobriansky alexei-dobriansky requested a review from a team as a code owner May 22, 2026 12:21
@alexei-dobriansky alexei-dobriansky enabled auto-merge (squash) May 22, 2026 12:22
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label May 22, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

$\textbf{🟠\ High\ Severity\ —\ Performance} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

Gen. Prod. Posting Group no longer auto-populated

Removing the OnValidate trigger on 'Subc. Work Center No.' means that when a user sets or changes the work center on a subcontracting transfer line, 'Gen. Prod. Posting Group' will no longer be automatically copied from the Work Center record. This breaks the previously established behavior and can leave transfer lines with an empty or stale posting group, potentially causing posting errors or incorrect G/L account assignments at the time of transfer posting.

Recommendation:

  • If the logic was intentionally removed (e.g., the field is always populated upstream before the transfer line is created), document why the auto-population is no longer needed and add a test that verifies posting succeeds without it. If it was removed by mistake, restore the trigger. If the logic has been moved elsewhere (e.g., to a codeunit that creates the transfer line), confirm that all code paths that set 'Subc. Work Center No.' also set 'Gen. Prod. Posting Group' correctly.
trigger OnValidate()
var
    WorkCenter: Record "Work Center";
begin
    if "Subc. Work Center No." = '' then
        exit;

    WorkCenter.Get("Subc. Work Center No.");
    "Gen. Prod. Posting Group" := WorkCenter."Gen. Prod. Posting Group";
end;

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

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

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant