[Master] Bug 645040: Expense Agent: BC Approval Workflow - Improve error message when Approval User Setup is missing - #10890
Conversation
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
Good Sense Reviewer - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThe change replaces the generic missing Problem-solution fitFit: 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. SuggestionsS1 (🟠 Moderate): Add coverage for the missing setup error Risk assessment and necessityRisk: The regression surface is limited to Expense Agent approval workflow page opening and 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.
|
Good Sense Reviewer - Round 2Recommendation: AcceptWhat this PR doesThe 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
New observations (commits since round 1)None - changes only addressed prior suggestions. Risk assessment and necessityRisk: 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.
|
|
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 |
Good Sense Reviewer - Round 3Recommendation: AcceptWhat this PR doesThe 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
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 necessityRisk: 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.
|
|
Improve missing User Setup ErrorInfo details, privacy classification, permission-aware messaging, partial record loading, and approval test fixtures.
Good Sense Reviewer - Round 4Recommendation: Accept with SuggestionsWhat this PR doesThe PR replaces generic missing Status of previous suggestions
New observations (commits since round 3)S2 (🟠 Moderate): Keep the missing setup tests specific Risk assessment and necessityRisk: 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.
|
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
GetCurrentUserSetupForApprovalin codeunitExpense Report Approval Mgmt. When the current user has noUser Setup, it raises an actionableErrorInfo: "Please configure your user '<username>' on the User Setup page, as the approval workflow for expenses is enabled."Approval User Setup), shown only when the user has read permission onUser Setup.UserSetup.Get(UserId())calls through the helper on theExpense Report,Expense Report List,Expense Reports,Manager Expense ReportandManager Expense Reportspages, and theExpense Report Headertable (CheckExpenseUserWhenApprovalIsEnabled). The already-guarded lookup inGetRecallActorRoleis unchanged.