Skip to content

Expense Agent: require Employee Posting Group when linking an expense user - #10803

Closed
v-rohangarg20 wants to merge 1 commit into
mainfrom
fix/645043-expense-user-employee-posting-group
Closed

Expense Agent: require Employee Posting Group when linking an expense user#10803
v-rohangarg20 wants to merge 1 commit into
mainfrom
fix/645043-expense-user-employee-posting-group

Conversation

@v-rohangarg20

@v-rohangarg20 v-rohangarg20 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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.
  • Added the Employee Posting Group lookup FlowField (field 25) on Expense User and filtered on it in Expense Users API OnOpenPage (FilterGroup 2, next to the existing Employee No. filter). This also covers employees whose posting group is removed after the link was made.

Tests

  • ExpenseUserCannotBeLinkedToEmployeeWithoutPostingGroup
  • ExpenseUserCanBeLinkedToEmployeeWithPostingGroup

… 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.
@v-rohangarg20
v-rohangarg20 requested a review from a team August 31, 2026 07:45
@v-rohangarg20
v-rohangarg20 requested a review from a team as a code owner August 31, 2026 07:45
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Team: Finance GitHub request for Finance area labels Aug 31, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Aug 31, 2026
@v-rohangarg20

Copy link
Copy Markdown
Contributor Author

Superseded by #10804 (branch renamed to bugs/645043-expense-user-employee-posting-group).

@v-rohangarg20
v-rohangarg20 deleted the fix/645043-expense-user-employee-posting-group branch August 31, 2026 07:47
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

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

@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

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

@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟠\ High\ Severity\ —\ Error\ Handling}$

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

@github-actions

Copy link
Copy Markdown
Contributor

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

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

@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟠\ High\ Severity\ —\ Web\ Services}$

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

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.

1 participant