microsoft / microsoft/BCApps

[Bug]: Mfg. Navigate Mgt. subscribes to OnBeforeShowRecords instead of OnAfterShowRecords, making the behavior impossible to override

Open Beginner friendly
#11,530 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team: SCM
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

Describe the issue

Codeunit 99000994 Mfg. Navigate Mgt. subscribes to Navigate.OnBeforeShowRecords to show the Production Order List page:

[EventSubscriber(ObjectType::Page, Page::Navigate, 'OnBeforeShowRecords', '', true, false)]
local procedure OnBeforeShowRecords(var TempDocumentEntry: Record "Document Entry"; DocNoFilter: Text; PostingDateFilter: Text; var IsHandled: Boolean; ContactNo: Code[250])
begin
    case TempDocumentEntry."Table ID" of
        Database::"Production Order":
            begin
                SetProdOrderFilters(DocNoFilter);
                Page.Run(0, ProductionOrderHeader);
            end;
    end;
end;

This subscriber does not follow the standard IsHandled guard pattern:

  1. It never checks IsHandled before executing, so it runs even if another subscriber already handled the Production Order case.
  2. It never sets IsHandled := true after running, so any logic that runs after this event (including the base Navigate.OnBeforeShowRecords publisher body) still executes for the "Production Order" table ID.

Because this logic sits in OnBeforeShowRecords (a "before" event) rather than OnAfterShowRecords (an "after" event) and doesn't set IsHandled, a partner/AppSource extension can no longer reliably override how Production Order document entries are opened from Navigate. Any subscriber added to OnBeforeShowRecords to customize this behavior would need to run before this one in an undefined subscriber order, and even then couldn't cleanly suppress this default handling since IsHandled is never respected here.

Expected behavior

The logic should be moved to OnAfterShowRecords:

    [EventSubscriber(ObjectType::Page, Page::Navigate, 'OnAfterShowRecords', '', true, false)]
    local procedure OnAfterShowRecords(var DocumentEntry: Record "Document Entry"; DocNoFilter: Text; PostingDateFilter: Text; ItemTrackingSearch: Boolean; ContactType: Enum "Navigate Contact Type"; ContactNo: Code[250]; ExtDocNo: Code[250])
    begin
        case DocumentEntry."Table ID" of
            Database::"Production Order":
                begin
                    SetProdOrderFilters(DocNoFilter);
                    Page.Run(0, ProductionOrderHeader);
                end;
        end;
    end;
Steps to reproduce
  1. Create an extension that subscribes to Navigate.OnBeforeShowRecords, checks for TempDocumentEntry."Table ID" = Database::"Production Order", implements custom logic, and sets IsHandled := true.
  2. Open the Navigate page for a document linked to a Production Order.
  3. Observe that the base Mfg. Navigate Mgt. subscriber still runs (or races with the custom one), because it ignores IsHandled and is wired to the "before" event.
Additional context

No response

I will provide a fix for a bug
  • I will provide a fix for a bug

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in codeunit 99000994, Mfg. Navigate Mgt., at the OnBeforeShowRecords subscriber shown in the issue, and compare it with the OnAfterShowRecords signature provided. Verify the Production Order case and extension override behavior; done means a partner subscriber can handle the case without the default logic also opening the Production Order page.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.