Skip to content

[main]- Requests to Approve: Open Record shows wrong Requisition Worksheet batch after viewing a different batch#9538

Open
v-ankitgoyal wants to merge 8 commits into
mainfrom
bugs/Bug-642418-Master-Requests-to-Approve-Open-Record
Open

[main]- Requests to Approve: Open Record shows wrong Requisition Worksheet batch after viewing a different batch#9538
v-ankitgoyal wants to merge 8 commits into
mainfrom
bugs/Bug-642418-Master-Requests-to-Approve-Open-Record

Conversation

@v-ankitgoyal

@v-ankitgoyal v-ankitgoyal commented Jul 16, 2026

Copy link
Copy Markdown

Fixes AB#642418

Issue: - Requests to Approve: Open Record shows wrong Requisition Worksheet batch after viewing a different batch

Root cause: -
When the worksheet is opened positioned on a specific batch record (for example, via Page Management from an approval entry's Open Record), the Requisition Line carries both Journal Batch Name and Worksheet Template Name. Page 291's OnOpenPage only short-circuited when Worksheet Template Name = '' (OpenedFromBatch), so with the template populated it fell through to the template-selection path. Because the page uses SaveValues = true, CurrentJnlBatchName was restored from the previously viewed batch, and OpenJnl filtered on that stale batch instead of the record's actual batch.

Solutions: -
Added a dedicated GetCurrentJnlBatchName() helper, called from OnOpenPage, that detects when the page is opened on a specific batch record and uses the batch from the record (overriding the SaveValues-restored value), scoping the page to the record's template:

// OnOpenPage
if OpenedFromBatch then begin
CurrentJnlBatchName := Rec."Journal Batch Name";
ReqJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);
SetControlAppearanceFromWkshBatch();
exit;
end;

if OpenedFromWkshBatchRecord() then
exit;

OnBeforeTemplateSelection(Rec, CurrentJnlBatchName);

// helper
local procedure GetCurrentJnlBatchName(): Boolean
begin
if (Rec."Journal Batch Name" = '') or (Rec."Worksheet Template Name" = '') then
exit(false);

CurrentJnlBatchName := Rec."Journal Batch Name";
Rec.FilterGroup := 2;
Rec.SetRange("Worksheet Template Name", Rec."Worksheet Template Name");
Rec.FilterGroup := 0;
ReqJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);
SetControlAppearanceFromWkshBatch();
exit(true);

end;

@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 16, 2026
@v-ankitgoyal

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

@JesperSchulz JesperSchulz added Ownership: Manual Preserve the manually selected team ownership SCM GitHub request for SCM area labels Jul 17, 2026
@v-ankitgoyal
v-ankitgoyal marked this pull request as ready for review July 17, 2026 06:34
@v-ankitgoyal
v-ankitgoyal requested a review from a team July 17, 2026 06:34
@v-ankitgoyal
v-ankitgoyal requested a review from a team July 17, 2026 06:40
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 3 · 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
Style 1 1 0 0 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.

@JesperSchulz JesperSchulz removed the Ownership: Manual Preserve the manually selected team ownership label Jul 17, 2026
@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.

ReqJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);
SetControlAppearanceFromWkshBatch();
exit(true);
end

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\ —\ Style} \quad \color{gray}{\texttt{\small Iteration\ 2}}$

In the new local procedure GetCurrentJnlBatchName, the then-branch of the if already ends with a terminating exit(true), so the following else exit(false) is structural noise.

Per BCQuality style guidance, drop the else and let exit(false) fall through unconditionally after the if block.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

        end;
        exit(false);

Knowledge:

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

Rec.FilterGroup := 2;
Rec.SetRange("Worksheet Template Name", Rec."Worksheet Template Name");
Rec.FilterGroup := 0;
ReqJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);

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}$

The new GetCurrentJnlBatchName() branch calls ReqJnlManagement.OpenJnl(...) and exits without firing the existing OnBeforeOpenReqWorksheet publisher. That creates an open-path for the worksheet that bypasses the established OnBefore extension point, so subscribers cannot participate when Open Record rehydrates the batch context. Consider raising OnBeforeOpenReqWorksheet(CurrentJnlBatchName) before opening the journal in this branch as well; the same shape is duplicated in the NA variant. Note: this mirrors the pre-existing OpenedFromBatch branch a few lines above, which already skips this event in an analogous direct-reopen scenario, so this may be an intentional, established convention rather than a new regression.

Knowledge:

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

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

Labels

SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants