Expense Agent: require Employee Posting Group when linking an expense user - #10803
Expense Agent: require Employee Posting Group when linking an expense user#10803v-rohangarg20 wants to merge 1 commit into
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.
|
Superseded by #10804 (branch renamed to bugs/645043-expense-user-employee-posting-group). |
|
The new FilterGroup 2 filter on "Employee Posting Group" changes the externally observable contract of API page 6918 "Expense Users API": expense users that were previously returned now disappear whenever the linked employee has a blank posting group. This is an advisory agent finding, but for API consumers it behaves like a breaking change because existing records become indistinguishable from "not found". Keep the existing collection shape stable and expose posting-group readiness separately, or version the API behavior explicitly. 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 |
|
Adding a new error to the existing "Employee No." validation path changes the shipped behavior of table 6923 "Expense User": code and UI flows that previously linked an employee now fail when that employee has no posting group. This is an advisory agent finding, but in practice it can break existing integrations and customer data-maintenance flows. Preserve the old linking contract and enforce the posting-group requirement in a compatible way, such as at posting/submission time or behind a migration/grandfathering path. 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 |
|
This validation already knows the exact Employee record that must be corrected, but it raises a plain Error with no recommended action. Use ErrorInfo with a Show-it navigation action (RecordId/PageNo plus AddNavigationAction) so the user can open the Employee and set Employee Posting Group instead of being left at a dead-end dialog. 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 |
|
The new negative test pins asserterror to a test-local copy of the full production error sentence (EmployeePostingGroupMissingErr). That still leaves the assertion coupled to duplicated message text instead of a shared assert helper or a stable invariant fragment, so wording drift between app and test can break or misdirect the check even when the validation behavior is still correct. 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 |
|
This API now decides gateway sign-in eligibility in OnOpenPage() by filtering out users with no linked employee or no employee posting group, but it still leaves reads at the default isolation. A concurrent uncommitted change to either value can therefore make the gateway temporarily admit or reject a user based on data that later rolls back. Set Rec.ReadIsolation := IsolationLevel::ReadCommitted; before applying the filters so the endpoint exposes only committed eligibility data. 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);
end;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 |
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