Repository navigation
[29.1] Don't reuse a Payables Agent user that has no permissions in the company - #14674
Jatin Kumar (Explorer986) wants to merge 1 commit into
Conversation
Good Sense Reviewer - Round 1Recommendation: Accept with SuggestionsWhat this PR doesRejects a same-name Payables Agent that cannot access the current company. This lets setup create a replacement when a company has been deleted and recreated with the same name. The check uses the same allowed-company query and current-company filter as task creation. Clearing the rejected Problem-solution fitFit: Strong The change addresses the stale-agent permission failure at discovery instead of granting permissions to the old user. It stays focused on name-based fallback; the separate activation terms and mailbox checks are unchanged. SuggestionsS1 (🟠 Moderate): Add regression coverage for fallback agent eligibility Risk assessment and necessityRisk: Low and limited to name-based discovery when the configured agent cannot be found. The company-access check matches task creation, including all-company permissions. Public signatures, posting logic, amounts and ledger entries are unchanged. The coverage gap is non-blocking; this review is source-only, with no independent release-specific runtime verification. Necessity: Without this change, a surviving same-name agent without current-company access can be reused and the first task fails. Recovery otherwise requires repairing agent setup or permissions. The small release adaptation is proportionate to that failure.
|
Backport of #14527
Backports #14527 to
releases/29.1.What & why
When a company is deleted and recreated with the same name, the agent user of the deleted company still exists in the environment, with the same agent user name. The setup found it by that name and reused it, but its permissions belonged to the deleted company, so the first task (an uploaded invoice or the trial upload) failed with "The task cannot be set to ready because the agent has no access control permissions in the ... company".
Now the lookup by user name only reuses an agent that can access the current company, using the same check the agent framework runs before it accepts a task. Otherwise the setup creates a new agent, which gets its default permissions when it's created, so the first task works. An agent linked in the company's setup is used as before.
On this release the Payables Agent setup code is still in one codeunit, so the same change is made in
GetAgentthere.Linked work
Fixes AB#661009
Risk & compatibility
Low. Only the fallback by user name changes, and only for an agent without access to the current company, which couldn't process tasks there anyway.