[Master] - Bug 645043: [Expense Agent] Expense User with missing Employee Posting Group is exposed through the Expense Users API and gets stuck at submission - #10804
Conversation
… user Bug 645043: an expense user linked to an employee without an employee posting group was exposed through the Expense Users API and got stuck at submission. - Expense User."Employee No." validation now blocks employees without an employee posting group. - Added an "Employee Posting Group" lookup FlowField on Expense User and filtered it out in the Expense Users API OnOpenPage, for employees that lose the posting group later. - Added tests for both the blocked and the allowed link.
Good Sense Reviewer - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis change stops Expense Users whose linked employee has no Employee Posting Group from being visible through the Problem-solution fitFit: Strong The reported scenario is an expense user who can sign in but cannot submit because the linked employee is missing required posting setup. The API filter handles existing bad data, and the table validation prevents the same bad link from being created again. SuggestionsS1 (🟠 Moderate): API filter lacks end-to-end coverage Risk assessment and necessityRisk: This touches sign-in eligibility for Expense Agent users and an Expense User validation path. The behavior is narrow, but an incorrect API filter would either still admit users who cannot submit expenses or hide valid users from the agent. The new table validation can affect setup/import flows that link users before employee posting setup is complete; that matches the posting requirement. Necessity: The change is needed because expense submission already rejects a missing Employee Posting Group later. Blocking or hiding the user before sign-in is a clearer failure mode than allowing login and failing at submit/posting.
|
…645043-expense-user-employee-posting-group
|
This API page now decides sign-in eligibility in OnOpenPage, so callers depend on it exposing only committed rows. Without Rec.ReadIsolation := IsolationLevel::ReadCommitted;, a concurrent uncommitted change to Employee No. or Employee Posting Group can transiently hide or surface a user that is later rolled back. Set read isolation before applying the filters. Suggested fix (apply manually — could not be anchored as a one-click suggestion): begin
Rec.ReadIsolation := IsolationLevel::ReadCommitted;
// Expense Users without a linked Employee No. cannot post expenses
// (validation fails at submission), so don't surface them to the agent
// gateway. The gateway treats an absent user as "not in this environment"
// and blocks sign-in there. Apply the constraint in FilterGroup 2 so it
// AND-combines with any caller-supplied $filter on Employee No., rather
// than replacing it in the default FilterGroup 0.
// The same applies when the employee posting group was removed from the
// employee after the expense user was linked.
OriginalFilterGroup := Rec.FilterGroup();
Rec.FilterGroup(2);
Rec.SetFilter("Employee No.", '<>%1', '');
Rec.SetFilter("Employee Posting Group", '<>%1', '');
Rec.FilterGroup(OriginalFilterGroup);Knowledge: Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
Good Sense Reviewer - Round 2Recommendation: Accept with SuggestionsWhat this PR doesThis PR blocks Expense Users whose linked employee has no Employee Posting Group from reaching the agent-facing API, and it prevents new invalid links through Status of previous suggestions
New observations (commits since round 1)None - the new commit only adjusts ES demo-data setup order and does not add a new review finding. Risk assessment and necessityRisk: This still touches sign-in eligibility for Expense Agent users, setup validation for Expense Users, and demo-data creation order. The ES reorder is narrow: it sets employee posting groups before creating Expense Users and still includes ES when country-specific expense data is created. The remaining risk is that the API FlowField filter is not proven through the published endpoint. Necessity: The change is needed because expense submission already requires an Employee Posting Group. The new ES ordering is also needed because the table validation would otherwise reject demo Expense Users before the country employee setup runs.
|
| OriginalFilterGroup := Rec.FilterGroup(); | ||
| Rec.FilterGroup(2); | ||
| Rec.SetFilter("Employee No.", '<>%1', ''); | ||
| Rec.SetFilter("Employee Posting Group", '<>%1', ''); |
There was a problem hiding this comment.
I wonder if we should completely block expense report line creation or let the admin fix the posting group during posting. That way we only block the posting scenarios.
However, the pro of this check is that the expense user config will be complete.
There was a problem hiding this comment.
Please seek Toto's opinion.
|
Fixes AB#645043
Problem
An expense user linked to an employee without an Employee Posting Group was returned by the Expense Users API. The agent could sign that user in, but submission/posting later failed because the posting group is required.
Changes
Expense User.Employee No.validation now errors when the employee has no employee posting group, so such a link cannot be created.Employee Posting Grouplookup FlowField (field 25) onExpense Userand filtered on it inExpense Users APIOnOpenPage(FilterGroup 2, next to the existingEmployee No.filter). This also covers employees whose posting group is removed after the link was made.Tests
ExpenseUserCannotBeLinkedToEmployeeWithoutPostingGroupExpenseUserCanBeLinkedToEmployeeWithPostingGroup