[Bug]: Mfg. Navigate Mgt. subscribes to OnBeforeShowRecords instead of OnAfterShowRecords, making the behavior impossible to override
Nobody has claimed this yet.
- 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:
- It never checks
IsHandledbefore executing, so it runs even if another subscriber already handled theProduction Ordercase. - It never sets
IsHandled := trueafter running, so any logic that runs after this event (including the baseNavigate.OnBeforeShowRecordspublisher 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
- Create an extension that subscribes to
Navigate.OnBeforeShowRecords, checks forTempDocumentEntry."Table ID" = Database::"Production Order", implements custom logic, and setsIsHandled := true. - Open the Navigate page for a document linked to a Production Order.
- Observe that the base
Mfg. Navigate Mgt.subscriber still runs (or races with the custom one), because it ignoresIsHandledand 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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