---
id: object/codeunit/4400
type: object
title: Codeunit 4400 "SOA Setup"
summary: Codeunit 4400 "SOA Setup" in SalesOrderAgent (Microsoft.Agent.SalesOrderAgent). 50 public procedures. Introduced in BC29, still in BC30.
tier: official
language: en
tags:
  - codeunit
  - salesorderagent
versions:
  introduced: "29"
  last_changed: null
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 1e314787151c56ca6503331ce65b0d199bf6ed9046626d5753d2204cbf345f3f
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/SalesOrderAgent/app/src/Setup/SOASetup.Codeunit.al
    title: src/Apps/W1/SalesOrderAgent/app/src/Setup/SOASetup.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/10772
    - change/bcapps/10665
    - change/bcapps/10308
    - change/bcapps/9606
    - change/bcapps/9365
object_type: codeunit
object_id: 4400
name: SOA Setup
namespace: Microsoft.Agent.SalesOrderAgent
app: SalesOrderAgent
extends: null
first_version: "29"
last_version: "30"
present_in:
  - "29"
  - "30"
changed_in: []
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 76
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 15
  called_by: 26
  implements: 0
---

# Codeunit 4400 "SOA Setup"

> Codeunit 4400 "SOA Setup" in SalesOrderAgent (Microsoft.Agent.SalesOrderAgent). 50 public procedures. Introduced in BC29, still in BC30.

SalesOrderAgent · Microsoft.Agent.SalesOrderAgent · BC29-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/SalesOrderAgent/app/src/Setup/SOASetup.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Internal |
| Permissions | tabledata "Email Inbox" = rd |

## Procedures

- `CreateDefaultAgentNoEmail()`: Used for testing OnPrem
- `GetInitials(): Text[4]` (internal)
- `GetInitials(AgentUserSecurityID: Guid): Text[4]` (internal)
- `GetAgentType(): Text` (internal)
- `GetAgentSummary(): Text` (internal)
- `AllowCreateNewSOAgent(): Boolean` (internal)
- `ActiveSOAgentCount(OwnerUserSecurityID: Guid): Integer` (internal): Counts the Sales Order Agent instances owned by a user that still occupy a slot. Archived agents are excluded because they can never be reactivated.
- `ActiveSOAgentSetupExists(): Boolean` (internal): Tells whether the company has at least one Sales Order Agent that is not archived. Kept to two bounded queries because callers include paths that run for ordinary users.
- `CountNonArchivedSetups(var SOASetup: Record "SOA Setup"): Integer` (internal): Counts the records in an already filtered set of setup records whose agent is not archived.
- `FindFirstNonArchivedSetup(var SOASetup: Record "SOA Setup"): Boolean` (internal): Finds the first record in an already filtered set of setup records whose agent is not archived.
- `IsAgentArchived(AgentUserSecurityID: Guid): Boolean` (internal)
- `IsAgentActive(AgentUserSecurityID: Guid): Boolean` (internal): Tells whether the agent behind a setup record is currently live, meaning it exists, is enabled and is not archived. Sessions that cannot read the Agent table get true, so callers never act on a state they were unable to determine.
- `MustTreatAgentAsArchived(AgentUserSecurityID: Guid): Boolean` (internal): Archived state for callers that block an operation. Unlike IsAgentArchived this fails closed: an agent whose state cannot be read is treated as archived, so the guard cannot be bypassed by running without access to the Agent table.
- `CheckAgentNotArchived(AgentUserSecurityID: Guid)` (internal)
- `MaxSOAInstances(): Integer` (internal)
- `GetDispatcherBaseDelaySeconds(): Integer` (internal)
- `GetDispatcherDelayIncrementSeconds(): Integer` (internal)
- `UpdateAgent(var AgentSetupBuffer: Record "Agent Setup Buffer"; var TempSOASetup: Record "SOA Setup" temporary; Schedule: Boolean)` (internal)
- `GetDefaultEmailSignatureAsTxt(): Text` (internal)
- `UpdateInstructions(var TempSOASetup: Record "SOA Setup" temporary)` (internal)
- `InstructionsSyncRequired(var SOASetup: Record "SOA Setup"): Boolean` (internal)
- `UpdateSOASetupInstructionsLastSync(var SOASetup: Record "SOA Setup")` (internal)
- `UpdateSOASetupActivationDT(var TempSOASetup: Record "SOA Setup" temporary)` (internal)
- `GetDefaultAgentAccessControl(AgentUserSecurityID: Guid; var TempAgentAccessControl: Record "Agent Access Control" temporary)` (internal)
- `GetDefaultProfile(var TempAllProfile: Record "All Profile" temporary)` (internal)
- `GetDefaultAccessControls(var TempAccessControlBuffer: Record "Access Control Buffer" temporary)` (internal)
- `GetSOASetup(var TempSOASetup: Record "SOA Setup" temporary; AgentUserSecurityID: Guid)` (internal)
- `CheckSOASetupStillValid(var SOASetup: Record "SOA Setup"): Boolean` (internal)
- `ValidateAgentIdentity(SOASetup: Record "SOA Setup")` (internal)
- `CheckMailboxUnique(SOASetup: Record "SOA Setup")` (internal)
- `GetEmailAccount(var SOASetup: Record "SOA Setup"; var TempEmailAccount: Record "Email Account" temporary)` (internal)
- `GetDefaultEmailAccount(var TempEmailAccount: Record "Email Account" temporary)` (internal)
- `GetAgentTaskUserInterventionSuggestions(AgentTaskUserInterventionRequestDetails: Record "Agent User Int Request Details"; var AgentTaskUserInterventionSuggestion: Record "Agent Task User Int Suggestion")` (internal)
- `GetAgentTaskPageContext(AgentTaskPageContextRequest: Record "Agent Task Page Context Req."; var AgentTaskPageContext: Record "Agent Task Page Context")` (internal)
- `GetCommunicationLanguageCodeAndFormat(AgentTaskId: BigInteger; var LanguageCode: Code[10]; var FormatRegion: Text[80])` (internal): By priority: from the contact card, from the customer card, or from the user settings.
- `GetSOAUserDisplayName(): Text[80]` (internal)
- `GetSOAUserDisplayName(AgentName: Text[50]): Text[80]` (internal)
- `GetSOAUsername(): Text[50]` (internal)
- `ValidateEmailConnectionStatus(var TempSOASetup: Record "SOA Setup" temporary): Boolean` (internal)
- `ValidateEmailConnection(StateChanged: Boolean; var TempSOASetup: Record "SOA Setup" temporary; MailboxChanged: Boolean; IsFirstActivation: Boolean)` (internal)
- `GetInboxEmailCount(var SOASetup: Record "SOA Setup"): Integer` (internal)
- `SupportedAttachmentContentType(FileMIMEType: Text): Boolean`
- `IsPdfAttachmentContentType(FileMIMEType: Text): Boolean` (internal)
- `IsImageAttachmentContentType(FileMIMEType: Text): Boolean` (internal)
- `DocumentExceedsPageCountThreshold(DocInStream: Instream; var Exceeds: Boolean)` (internal)
- `PageCountThreshold(): Integer` (internal)
- `GetMaxNoOfAttachmentsPerEmail(): Integer` (internal)
- `GetFeatureName(): Text` (internal)
- `GetUpdatedQuoteInterventionSuggestionCode(): Code[20]` (internal)
- `GetUpdatedOrderInterventionSuggestionCode(): Code[20]` (internal)

Plus 26 local procedures.

## Calls

From the extracted call graph of BC29 (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 4305 "SOA Filters Impl."](../codeunit/4305.md) (5 calls: `GetAgentTaskPageContext → GetSecurityFiltersForContacts`, `GetAgentTaskPageContext → GetSecurityFiltersForCustomers`, `GetCommunicationLanguageCodeAndFormat → GetExcludeAllFilter`, …)
- [Codeunit 4397 "SOA Test Setup"](../codeunit/4397.md) (5 calls: `GetEmailsCount → (object)`, `GetEmailsCount → GetEmailCount`, `GetEmailsCount → SetTestEmailCount`, …)
- [Codeunit 4321 "Agent"](../codeunit/4321.md) (4 calls: `GetDefaultAgentAccessControl → GetUserAccess`, `GetDefaultProfile → PopulateDefaultProfile`, `LogTelemetry → GetUserSettings`, …)
- [Codeunit 4324 "Agent Setup"](../codeunit/4324.md) (4 calls: `CreateAgent → SaveChanges`, `CreateDefaultAgentNoEmail → GetSetupRecord`, `CreateDefaultAgentNoEmail → SaveChanges`, …)
- [Codeunit 4587 "SOA Impl"](../codeunit/4587.md) (3 calls: `CreateAgent → ScheduleSOAgent`, `UpdateAgent → RemoveScheduledTask`, `UpdateAgent → ScheduleSOAgent`)
- [Codeunit 43 "Language"](../codeunit/43.md) (2 calls: `GetAgentTaskPageContext → GetLanguageId`, `LogTelemetry → GetCultureName`)
- [Codeunit 8894 "Email Account"](../codeunit/8894.md) (2 calls: `GetDefaultEmailAccount → GetAllAccounts`, `GetEmailAccount → GetAllAccounts`)
- [Codeunit 9024 "Azure AD Graph User"](../codeunit/9024.md) (2 calls: `UpdateAgent → IsUserDelegatedAdmin`, `UpdateAgent → IsUserDelegatedHelpdesk`)
- [Codeunit 3110 "PDF Document"](../codeunit/3110.md) (1 call: `DocumentExceedsPageCountThreshold → GetPdfPageCount`)
- [Codeunit 4002 "SOA Prompt Builder"](../codeunit/4002.md) (1 call: `UpdateInstructions → PrepareInstructions`)
- [Codeunit 4317 "Agent System Permissions"](../codeunit/4317.md) (1 call: `AllowCreateNewSOAgent → CurrentUserHasCanManageAllAgentsPermission`)
- [Codeunit 4395 "Global Item Search"](../codeunit/4395.md) (1 call: `EnableItemSearch → EnableItemSearch`)
- [Codeunit 4396 "SOA Email Setup"](../codeunit/4396.md) (1 call: `UpdateSyncDateTime → GetMaxNoOfEmails`)
- [Codeunit 457 "Environment Information"](../codeunit/457.md) (1 call: `ValidateEmailConnection → IsSandbox`)
- [Codeunit 8703 "Feature Telemetry"](../codeunit/8703.md) (1 call: `LogTelemetry → LogUptake`)

## Called by

- [Codeunit 4582 "SOA Retrieve Emails"](../codeunit/4582.md) (16 calls: `AddEmailAttachmentToTaskMessage → DocumentExceedsPageCountThreshold`, `AddEmailAttachmentToTaskMessage → GetFeatureName`, `AddEmailAttachmentToTaskMessage → GetMaxNoOfAttachmentsPerEmail`, …)
- [Page 4400 "SOA Setup"](../page/4400.md) (14 calls: `ApplySetup → CheckMailboxUnique`, `ApplySetup → GetInboxEmailCount`, `ApplySetup → UpdateAgent`, …)
- [Codeunit 4399 "SOA Annotation"](../codeunit/4399.md) (7 calls: `AddAgentTaskFailureAnnotation → GetFeatureName`, `AddAgentTaskSendRepliesFailureAnnotation → GetFeatureName`, `AddOverProcessLimitAnnotation → GetFeatureName`, …)
- [Codeunit 4587 "SOA Impl"](../codeunit/4587.md) (7 calls: `GetInstanceOffset → CountNonArchivedSetups`, `RemoveScheduledTask → GetFeatureName`, `RemoveScheduledTasksIfAgentNotActive → GetFeatureName`, …)
- [Codeunit 4401 "SOA Metadata Provider"](../codeunit/4401.md) (6 calls: `CreateManualAgentTask → CheckAgentNotArchived`, `GetDefaultAccessControls → GetDefaultAccessControls`, `GetDefaultInitials → GetInitials`, …)
- [Codeunit 4589 "SOA Upgrade"](../codeunit/4589.md) (5 calls: `AlwaysUpdateAgentInstructionsOnUpgrade → MustTreatAgentAsArchived`, `TryUpdateAgentInstructions → UpdateInstructions`, `UpgradeAgentIdentity → GetInitials`, …)
- [Codeunit 4598 "SOA Instructions"](../codeunit/4598.md) (4 calls: `AddCultureToBroaderItemSearchSystemPrompt → GetCommunicationLanguageCodeAndFormat`, `AddCultureToBroaderItemSearchSystemPrompt → GetFeatureName`, `GetMailTemplateCheckSystemPrompt → GetFeatureName`, …)
- [Codeunit 4305 "SOA Filters Impl."](../codeunit/4305.md) (3 calls: `GetContactsInvolvedInTask → GetFeatureName`, `GetSecurityFiltersForCustomers → GetFeatureName`, `LogContactLinkChoice → GetFeatureName`)
- [Codeunit 4586 "SOA Dispatcher"](../codeunit/4586.md) (3 calls: `CanRunTask → GetFeatureName`, `RunSOAgent → CheckSOASetupStillValid`, `RunSOAgent → GetFeatureName`)
- [Codeunit 4304 "SOA Session Events"](../codeunit/4304.md) (2 calls: `BindUserEvents → GetFeatureName`, `SetupFilteringEvents → GetFeatureName`)
- [Codeunit 4309 "SOA Agent Task Execution"](../codeunit/4309.md) (2 calls: `GetAgentTaskPageContext → GetAgentTaskPageContext`, `GetAgentTaskUserInterventionSuggestions → GetAgentTaskUserInterventionSuggestions`)
- [Codeunit 4402 "SOA Output Message Setup"](../codeunit/4402.md) (2 calls: `GetSignatureText → GetDefaultEmailSignatureAsTxt`, `LogTelemetryError → GetFeatureName`)
- [Codeunit 4417 "SOA Item Selector"](../codeunit/4417.md) (2 calls: `LogItemSelectorException → GetFeatureName`, `LogItemSelectorResponseFailure → GetFeatureName`)
- [Codeunit 4581 "SOA Send Replies"](../codeunit/4581.md) (2 calls: `GiveUpOnDelivery → GetFeatureName`, `SendEmailReply → GetFeatureName`)
- [Codeunit 4002 "SOA Prompt Builder"](../codeunit/4002.md) (1 call: `BuildSignature → GetDefaultEmailSignatureAsTxt`)
- [Codeunit 4306 "SOA Session Filter"](../codeunit/4306.md) (1 call: `SetFilterOnSalesHeader → GetFeatureName`)
- [Codeunit 4323 "SOA Awareness Notifications"](../codeunit/4323.md) (1 call: `IsBindingNeeded → ActiveSOAgentSetupExists`)
- [Codeunit 4418 "SOA Reply Retry Mgt."](../codeunit/4418.md) (1 call: `RetrySending → GetFeatureName`)
- [Codeunit 4419 "SOA Send Reply"](../codeunit/4419.md) (1 call: `AddMessageAttachments → GetFeatureName`)
- [Codeunit 4421 "SOA Attachment MLLM"](../codeunit/4421.md) (1 call: `IsImageAttachment → IsImageAttachmentContentType`)
- [Codeunit 4584 "SOA Recovery"](../codeunit/4584.md) (1 call: `RunSOARecovery → GetFeatureName`)
- [Codeunit 4585 "SOA Error Handler"](../codeunit/4585.md) (1 call: `RunSOAErrorHandler → GetFeatureName`)
- [Codeunit 4590 "SOA Billing"](../codeunit/4590.md) (1 call: `LogSOATrackingRecord → GetFeatureName`)
- [Codeunit 4591 "SOA Item Search"](../codeunit/4591.md) (1 call: `LogTelemetryForFindItems → GetFeatureName`)
- [Codeunit 4600 "SOA Document Events"](../codeunit/4600.md) (1 call: `AddAttachmentsToDocument → GetFeatureName`)
- [Page 4402 "SOA KPI"](../page/4402.md) (1 call: `GetCurrentUserAgentSecurityID → FindFirstNonArchivedSetup`)

## Recent changes

- 2026-10-06 [#10772 [Bug Fix] #304: [SOA] Re-resolve new sender to created contact after 'I have added the contact'](../../changes/bcapps/10772.md) (main, BC30, fix)
- 2026-08-27 [#10665 [SOA] Skip content extraction for image attachments](../../changes/bcapps/10665.md) (main, BC30, fix)
- 2026-08-19 [#10308 Uptake agent archiving in Sales Order Agent (AB#644549)](../../changes/bcapps/10308.md) (main, BC30, feature)
- 2026-07-22 [#9606 [SOA] Disable available-items-only search by default](../../changes/bcapps/9606.md) (main, BC30, feature)
- 2026-07-22 [#9365 [SOA] Prevent translated username token and remove dead GetAgent helpers](../../changes/bcapps/9365.md) (main, BC30, fix)

## Across versions

- Present in: BC29-30
- Changed (declaration) in: none

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 BC29 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: "SOA Setup")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
