Skip to content

[Master] Bug 645040: Expense Agent: BC Approval Workflow - Improve error message when Approval User Setup is missing - #10890

Open
v-rohangarg20 wants to merge 4 commits into
mainfrom
bugs/Bug645040-improve-approval-user-setup-missing-error
Open

[Master] Bug 645040: Expense Agent: BC Approval Workflow - Improve error message when Approval User Setup is missing#10890
v-rohangarg20 wants to merge 4 commits into
mainfrom
bugs/Bug645040-improve-approval-user-setup-missing-error

Conversation

@v-rohangarg20

@v-rohangarg20 v-rohangarg20 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#645040

Problem

When the BC approval workflow is enabled and the current user has no User Setup record, opening an expense report (or the related list / manager pages) failed with the generic platform error "The User Setup does not exist. Identification fields and values: User ID='…'" — cryptic and non-actionable.

Changes

  • Added an internal helper GetCurrentUserSetupForApproval in codeunit Expense Report Approval Mgmt. When the current user has no User Setup, it raises an actionable ErrorInfo: "Please configure your user '<username>' on the User Setup page, as the approval workflow for expenses is enabled."
  • The error carries a navigation action Open the Approval User Setup page (→ page Approval User Setup), shown only when the user has read permission on User Setup.
  • Routed the approval-workflow UserSetup.Get(UserId()) calls through the helper on the Expense Report, Expense Report List, Expense Reports, Manager Expense Report and Manager Expense Reports pages, and the Expense Report Header table (CheckExpenseUserWhenApprovalIsEnabled). The already-guarded lookup in GetRecallActorRole is unchanged.

When the approval workflow is enabled and the current user has no User Setup
record, opening an expense report failed with the generic platform error
"The User Setup does not exist. Identification fields and values: User ID='...'".

Add an internal helper GetCurrentUserSetupForApproval in codeunit
"Expense Report Approval Mgmt" that raises an actionable ErrorInfo instead: a
clear message asking the user to configure their User Setup, plus a navigation
action to the Approval User Setup page (shown only when the user has read
permission on User Setup). Route the approval-workflow UserSetup.Get(UserId())
calls on the Expense Report, Expense Report List, Expense Reports, Manager
Expense Report and Manager Expense Reports pages and the Expense Report Header
table through it. The already-guarded lookup in GetRecallActorRole is unchanged.

AB#645040
@v-rohangarg20
v-rohangarg20 requested a review from a team September 1, 2026 11:36
@v-rohangarg20
v-rohangarg20 requested a review from a team as a code owner September 1, 2026 11:36
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Team: Finance GitHub request for Finance area labels Sep 1, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Sep 1, 2026
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Accept with Suggestions

What this PR does

The change replaces the generic missing User Setup lookup error with an actionable ErrorInfo when expense approval workflow is enabled. It routes the affected expense report pages and the table validation through one helper, so the same missing-setup case gets the new message before the code checks Unlimited Expense Approval. The fix is narrow and addresses the root cause for the changed entry points.

Problem-solution fit

Fit: Strong

The bug says users without a setup record get a generic error when approval workflow is enabled. The changed lookups are exactly the places that opened expense report pages or validated an expense user in that workflow, so the solution matches the reported behavior without changing approval rules.

Suggestions

S1 (🟠 Moderate): Add coverage for the missing setup error
Add a regression test for the case where approval workflow is enabled and the current user has no User Setup record. This would protect the new message and the navigation action from changing back to the generic platform error.

Risk assessment and necessity

Risk: The regression surface is limited to Expense Agent approval workflow page opening and Expense Report Header validation. The change does not alter posting, amounts, ledger data, public event signatures, or upgrade behavior. If it is wrong, the likely impact is a worse setup error or a missing navigation action, not changed expense approval decisions.

Necessity: The change is needed because the previous platform error did not tell the user how to fix the missing approval setup. The scope is appropriate because it centralizes the check and applies it only when expense approval workflow is enabled.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10890 round=1 by=alexei-dobriansky at=2026-09-01T13:16:30Z lastSha=63af53a5d3806dbe75016991fa1e0811ec77912b reviewKey=8666d5e97cc5bfc66277df799c047ff029811fab43a6047d78ea1db8878582da suggestions=S1@3776e34d

@v-rohangarg20 v-rohangarg20 changed the title [Bug 645040] Expense Agent: improve error message when Approval User Setup is missing [MASTER] Expense Agent: improve error message when Approval User Setup is missing Sep 2, 2026
@v-rohangarg20 v-rohangarg20 changed the title [MASTER] Expense Agent: improve error message when Approval User Setup is missing [Master] Expense Agent: improve error message when Approval User Setup is missing Sep 2, 2026
@v-rohangarg20 v-rohangarg20 changed the title [Master] Expense Agent: improve error message when Approval User Setup is missing [Master] Bug 645040: Expense Agent: BC Approval Workflow - Improve error message when Approval User Setup is missing Sep 2, 2026
Comment thread src/Apps/W1/ExpenseAgent/test/src/WFDemoExpReportApprovals.Codeunit.al Outdated
Comment thread src/Apps/W1/ExpenseAgent/test/src/WFDemoExpReportApprovals.Codeunit.al Outdated
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 2

Recommendation: Accept

What this PR does

The new commit adds regression coverage for the missing approval user setup scenario and keeps the helper wired through the same approval entry points. The added tests cover the helper when the current user has no setup record, the success path when the setup exists, and one page-open path, so the round-1 coverage gap is addressed. The wording-only label changes do not change approval flow or data behavior.

Status of previous suggestions
ID Title Status Author response
S1 Add coverage for the missing setup error Addressed Added helper and page regression tests for the missing setup error.
New observations (commits since round 1)

None - changes only addressed prior suggestions.

Risk assessment and necessity

Risk: The new commit mainly adds tests and changes error/action label wording. The remaining regression surface is limited to expense approval setup errors shown while opening expense report pages or validating an expense user; posting, amounts, ledger data, and public integration surfaces are not changed.

Necessity: The added coverage is needed because the bug depends on a missing setup record and should not regress to the generic platform error. The scope is still appropriate for the reported setup guidance issue.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10890 round=2 by=alexei-dobriansky at=2026-09-02T13:18:48Z lastSha=baec46e804bdfd8671e18f651df42fa08519a362 reviewKey=6987fe10199f87033ff8cc395bce21cb989973eba7abcfc8a568d1f32a2a4448 suggestions=S1@3776e34d:addressed parentRound=1

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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

CurrentUserSetupIsReturnedWhenPresentForApproval hand-builds the 'User Setup' fixture with Init/Insert even though this same test codeunit already has 'Library - Document Approvals'.CreateOrFindUserSetup for exactly this purpose (used elsewhere in the file, e.g. around lines 1302/1345). Using the library keeps the fixture aligned with future required-field/setup changes instead of duplicating schema knowledge in the test.

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

        LibraryDocumentApprovals.CreateOrFindUserSetup(UserSetup, CopyStr(UserId(), 1, MaxStrLen(UserSetup."User ID")));
        Clear(UserSetup);

Knowledge:

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

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

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 3

Recommendation: Accept

What this PR does

The PR replaces generic missing User Setup lookups in the expense approval flow with a helper that raises a clear client error and offers navigation to the setup page when that page can be read. The tests cover the helper error path, the successful setup lookup, and one page-open path. Since round 2, the only new code resets the approval workflow and agent flags before each approval test, which improves test isolation without changing product behavior.

Status of previous suggestions
ID Title Status Author response
S1 Add coverage for the missing setup error Addressed No new reply; the helper and page regression tests remain in place.
New observations (commits since round 2)

None - the new commit only resets approval and agent setup state in the approval test initialization.

Risk assessment and necessity

Risk: The new round-3 change is test-only. The product regression surface remains limited to expense approval page opening and expense user validation when approval workflow is enabled; posting, amounts, ledger data, public APIs, and event publishers are not changed.

Necessity: The reset is useful because the new missing-setup tests turn approval workflow on and can otherwise leave setup state for later tests. Keeping that state isolated makes the regression coverage more reliable.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10890 round=3 by=alexei-dobriansky at=2026-09-03T07:12:44Z lastSha=af6e88f25b8118bcc5cc2d7e55c7eccfa2d8eaba reviewKey=32d7830e6773062f1d4e11c7354bd9b3ffc8921c59c7d2edb1b4b0c3abdd1687 suggestions=S1@3776e34d:addressed parentRound=2

@github-actions

github-actions Bot commented Sep 7, 2026

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.

Improve missing User Setup ErrorInfo details, privacy classification, permission-aware messaging, partial record loading, and approval test fixtures.
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 4

Recommendation: Accept with Suggestions

What this PR does

The PR replaces generic missing User Setup lookups in the expense approval flow with a helper that raises a clear client error and offers setup navigation when the user can read the setup table. The tests cover the missing setup path, the success path, and one page-open path. Since round 3, the new commit makes the helper set its own load fields, adds title and detailed error text, uses a safer data classification for the user-specific message, adds a no-permission fallback message, and adjusts the tests. The product changes still fit the reported setup problem and do not change approval decisions.

Status of previous suggestions
ID Title Status Author response
S1 Add coverage for the missing setup error Addressed No new reply; the helper and page regression tests remain in place.
New observations (commits since round 3)

S2 (🟠 Moderate): Keep the missing setup tests specific
The new assertions only look for Please configure your user, so they would still pass if the error stopped naming the current user or explaining the approval workflow. Keep the normal-permission tests on the full message, or add a separate test for the no-permission fallback if this looser check is needed.

Risk assessment and necessity

Risk: The product regression surface remains limited to opening expense report pages and validating the expense user when approval workflow is enabled. The new code changes message metadata and permission-sensitive navigation behavior; it does not touch posting, amounts, ledger data, public APIs, or event publishers.

Necessity: The change is still needed because the missing setup case should tell the user how to fix approval setup instead of showing a generic record error. The round-4 refinements are useful because they make the helper more self-contained and avoid exposing user-specific text when the setup table cannot be read, but the tests should keep protecting the exact normal error message.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10890 round=4 by=alexei-dobriansky at=2026-09-07T13:56:31Z lastSha=3385017b38a6c73987dd565ae8e5bbe77ca890f8 reviewKey=2f94a34f1d6a24bcf3f1c327fb26cc60e4d0e6424fa20cd699b717fa0e6828ea suggestions=S1@3776e34d:addressed,S2@24b4e505:new parentRound=3

@v-rohangarg20
v-rohangarg20 added this pull request to the merge queue Sep 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 8, 2026
@v-rohangarg20
v-rohangarg20 added this pull request to the merge queue Sep 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 8, 2026
@v-rohangarg20 v-rohangarg20 reopened this Sep 9, 2026
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 Team: Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants