---
id: object/codeunit/3343
type: object
title: Codeunit 3343 "PA Setup"
summary: Codeunit 3343 "PA Setup" in PayablesAgent (Microsoft.Agent.PayablesAgent). 35 public procedures. Introduced in BC30.
tier: official
language: en
tags:
  - codeunit
  - payablesagent
versions:
  introduced: "30"
  last_changed: null
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-12-01T01:00:51.425Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 776d344e4628d73e3a23f325451a4d6cc1558637f7fe48d5062d791a90bd001c
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/f53bb0f1ecd89fde9f133f9dcaf5bf43cf5f2671/src/Apps/W1/PayablesAgent/app/Entities/Setup/PASetup.Codeunit.al
    title: src/Apps/W1/PayablesAgent/app/Entities/Setup/PASetup.Codeunit.al (main)
    date: null
    commit: f53bb0f1ecd89fde9f133f9dcaf5bf43cf5f2671
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/14527
    - change/bcapps/14442
    - change/bcapps/13361
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/payables-agent-setup
      title: Set Up Payables Agent in Business Central
      label: possibly related
      why: Setup codeunit configures Payables Agent mailbox monitoring, rules, and access control
      by: model
object_type: codeunit
object_id: 3343
name: PA Setup
namespace: Microsoft.Agent.PayablesAgent
app: PayablesAgent
extends: null
first_version: "30"
last_version: "30"
present_in:
  - "30"
changed_in: []
source_major: "30"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 37
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 4
  called_by: 17
  implements: 0
---

# Codeunit 3343 "PA Setup"

> Codeunit 3343 "PA Setup" in PayablesAgent (Microsoft.Agent.PayablesAgent). 35 public procedures. Introduced in BC30.

PayablesAgent · Microsoft.Agent.PayablesAgent · BC30 · [source at f53bb0f1](https://github.com/microsoft/BCApps/blob/f53bb0f1ecd89fde9f133f9dcaf5bf43cf5f2671/src/Apps/W1/PayablesAgent/app/Entities/Setup/PASetup.Codeunit.al) · facts from BC30

## Properties

| Property | Value |
|---|---|
| Access | Internal |
| Permissions | tabledata "Payables Agent Setup" = RIMD, tabledata Agent = R |

## Procedures

- `LoadOrCreateSetup()` (internal)
- `LoadStoredOrDefaults()` (internal)
- `TryFindAgent(var Agent: Record Agent): Boolean` (internal)
- `TryGetStoredAgent(var Agent: Record Agent): Boolean` (internal)
- `FindAgentAndReconcileSetup(var Agent: Record Agent): Boolean` (internal)
- `IsStoredAgentEnabled(): Boolean` (internal)
- `AgentUserName(): Code[50]` (internal)
- `GetPageRecord(): Record "Payables Agent Setup"` (internal)
- `ResetProposal()` (internal)
- `GetMonitorOutlook(): Boolean` (internal)
- `SetMonitorOutlook(Value: Boolean)` (internal)
- `GetEmailReviewPolicy(): Enum "PA Email Review Policy"` (internal)
- `SetEmailReviewPolicy(Value: Enum "PA Email Review Policy")` (internal)
- `SetMailboxSelection(AccountId: Guid; FolderName: Text[2048]; FolderId: Text[2048])` (internal)
- `GetEmailAccountId(): Guid` (internal)
- `GetEmailFolder(): Text[2048]` (internal)
- `GetEmailFolderId(): Text[2048]` (internal)
- `GetEmailMonitoringConsent(): Boolean` (internal)
- `SetEmailMonitoringConsent(Value: Boolean)` (internal)
- `GetLastSyncAt(): DateTime` (internal)
- `GetUserSecurityId(): Guid` (internal)
- `SetUserSecurityId(Value: Guid)` (internal)
- `GetLastActivated(): DateTime` (internal)
- `SetLastActivated(Value: DateTime)` (internal)
- `GetAppliedInstrConfigHash(): Text[64]` (internal)
- `SetAppliedInstrConfigHash(Value: Text[64])` (internal)
- `GetAgentProfile(): Text[30]` (internal)
- `GetAgentPermissionSet(): Code[20]` (internal)
- `SupportsEmailMonitoring(): Boolean` (internal)
- `SupportsAdditionalFields(): Boolean` (internal)
- `PrepareForApply(Enabling: Boolean)` (internal)
- `ApplySetup(Enabling: Boolean)` (internal)
- `SaveUserSecurityId(UserSecurityId: Guid)` (internal)
- `SaveAppliedInstrConfigHash(AppliedInstrConfigHash: Text[64])` (internal)
- `DeleteSetup(TargetCompanyName: Text[30])` (internal)

Plus 2 local procedures.

## Calls

From the extracted call graph of BC30 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 3338 "PA Draft Based Setup Store"](../codeunit/3338.md) (16 calls: `ApplySetup → DisableMonitoring`, `ApplySetup → Synchronize`, `GetEmailAccountId → GetEmailAccountId`, …)
- [Codeunit 3339 "PA V1V2 Flag"](../codeunit/3339.md) (5 calls: `LoadSetup → IsV2Active`, `PrepareForApply → IsV2Active`, `ResetProposal → IsV2Active`, …)
- [Codeunit 8894 "Email Account"](../codeunit/8894.md) (1 call: `ApplySetup → GetAllAccounts`)
- [Page extension 9204 "User Settings"](../pageextension/9204.md) (1 call: `CanAgentAccessCurrentCompany → (object)`)

## Called by

- [Codeunit 3344 "PA Setup Update"](../codeunit/3344.md) (17 calls: `ApplySetup → ApplySetup`, `ApplySetup → GetAppliedInstrConfigHash`, `ApplySetup → SetAppliedInstrConfigHash`, …)
- [Codeunit 3321 "PA Setup Update Parameters"](../codeunit/3321.md) (9 calls: `DisactivateEmailMonitoring → SetMonitorOutlook`, `GetEmailAccount → GetEmailAccountId`, `InitializeFromStoredSetup → AgentUserName`, …)
- [Codeunit 3326 "PA Test Fixtures"](../codeunit/3326.md) (7 calls: `Reset → ApplySetup`, `Reset → DeleteSetup`, `Reset → LoadOrCreateSetup`, …)
- [Codeunit 3352 "Payables Agent Metadata"](../codeunit/3352.md) (4 calls: `GetDefaultAccessControls → GetAgentPermissionSet`, `GetDefaultAccessControls → LoadStoredOrDefaults`, `GetDefaultProfile → GetAgentProfile`, …)
- [Codeunit 3317 "Payables Agent OCV"](../codeunit/3317.md) (3 calls: `HasProcessedEnoughDocumentsForFeedback → GetLastActivated`, `HasProcessedEnoughDocumentsForFeedback → LoadOrCreateSetup`, `HasProcessedEnoughDocumentsForFeedback → TryFindAgent`)
- [Codeunit 3349 "PA Agent Instructions"](../codeunit/3349.md) (3 calls: `EnsureAgentInstructionsMatchConfiguration → GetAppliedInstrConfigHash`, `EnsureAgentInstructionsMatchConfiguration → LoadStoredOrDefaults`, `SetAgentInstructions → SaveAppliedInstrConfigHash`)
- [Codeunit 3351 "PA Known Senders"](../codeunit/3351.md) (3 calls: `ShouldRequestReview → GetEmailFolder`, `ShouldRequestReview → GetEmailReviewPolicy`, `ShouldRequestReview → LoadOrCreateSetup`)
- [Page 3304 "Payables Agent Setup"](../page/3304.md) (3 calls: `OnAfterGetCurrRecord → SupportsEmailMonitoring`, `OnOpenPage → GetPageRecord`, `OnOpenPage → SupportsAdditionalFields`)
- [Page 3313 "PA Known Senders"](../page/3313.md) (3 calls: `OnOpenPage → GetEmailFolder`, `OnOpenPage → GetEmailReviewPolicy`, `OnOpenPage → LoadStoredOrDefaults`)
- [Codeunit 3310 "PA Validate Setup"](../codeunit/3310.md) (2 calls: `OnRun → GetEmailAccountId`, `OnRun → GetLastSyncAt`)
- [Codeunit 3318 "PA Trial"](../codeunit/3318.md) (2 calls: `IsEligibleToStart → GetUserSecurityId`, `IsEligibleToStart → LoadStoredOrDefaults`)
- [Codeunit 3325 "PA Telemetry"](../codeunit/3325.md) (2 calls: `EnsureSetupAndBuildWorkItemDimensions → GetEmailReviewPolicy`, `EnsureSetupAndBuildWorkItemDimensions → LoadOrCreateSetup`)
- [Codeunit 3350 "PA Agent Access"](../codeunit/3350.md) (2 calls: `AllowCreateNewAgent → TryGetStoredAgent`, `CanShowAgentActions → TryGetStoredAgent`)
- [Table 3308 "PA Known Sender"](../table/3308.md) (2 calls: `InsertSenderIfNew → GetEmailReviewPolicy`, `InsertSenderIfNew → LoadOrCreateSetup`)
- [Codeunit 3305 "Payables Agent Upgrade"](../codeunit/3305.md) (1 call: `AlwaysUpdateAgentInformationOnUpgrade → FindAgentAndReconcileSetup`)
- [Codeunit 3327 "PA Work Item Upload"](../codeunit/3327.md) (1 call: `ShowTaskPane → TryFindAgent`)
- [Codeunit 3345 "PA Work Item Intake"](../codeunit/3345.md) (1 call: `Admit → FindAgentAndReconcileSetup`)

## Recent changes

- 2026-11-26 [#14527 Don't reuse a Payables Agent user that has no permissions in the company](../../changes/bcapps/14527.md) (main, BC30, fix)
- 2026-11-25 [#14442 Offer the Payables Agent again in a company recreated with the same name](../../changes/bcapps/14442.md) (main, BC30, fix)
- 2026-11-14 [#13361 Foundation for Payables Agent V2.0](../../changes/bcapps/13361.md) (main, BC30, refactor, added)

## Across versions

- Present in: BC30
- Changed (declaration) in: none

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Set Up Payables Agent in Business Central](https://learn.microsoft.com/dynamics365/business-central/payables-agent-setup) — possibly related: Setup codeunit configures Payables Agent mailbox monitoring, rules, and access control (model-linked)

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC30 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "PA Setup")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
