---
id: object/codeunit/6989
type: object
title: Codeunit 6989 "Expense Attachment Mgt."
summary: Codeunit 6989 "Expense Attachment Mgt." in ExpenseAgent (Microsoft.ExpenseAgent). 2 public procedures, 16 event subscribers. Introduced in BC29, still in BC30.
tier: official
language: en
tags:
  - codeunit
  - expenseagent
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: 2a1087d77a6cbd2f839e04d82bcf4e012402a6143d035b527c44323fa1aaa77c
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/ExpenseAgent/app/src/Expense/Codeunits/ExpenseAttachmentMgt.Codeunit.al
    title: src/Apps/W1/ExpenseAgent/app/src/Expense/Codeunits/ExpenseAttachmentMgt.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/10828
    - change/bcapps/9859
object_type: codeunit
object_id: 6989
name: Expense Attachment Mgt.
namespace: Microsoft.ExpenseAgent
app: ExpenseAgent
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: 29
  events: 0
  subscribers: 16
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 4
  called_by: 2
  implements: 0
---

# Codeunit 6989 "Expense Attachment Mgt."

> Codeunit 6989 "Expense Attachment Mgt." in ExpenseAgent (Microsoft.ExpenseAgent). 2 public procedures, 16 event subscribers. Introduced in BC29, still in BC30.

ExpenseAgent · Microsoft.ExpenseAgent · BC29-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/ExpenseAgent/app/src/Expense/Codeunits/ExpenseAttachmentMgt.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Internal |

## Event subscriptions

- OnAfterInsertEvent subscribes to Table "Document Attachment" OnAfterInsertEvent
- OnBeforeImportFromStream subscribes to Table "Document Attachment" OnBeforeImportFromStream
- OnBeforeDeleteAttachment subscribes to Table "Document Attachment" OnBeforeDeleteEvent
- OnAfterModifyEvent subscribes to Table "Document Attachment" OnAfterModifyEvent
- OnAfterDeleteEvent subscribes to Table "Document Attachment" OnAfterDeleteEvent
- OnBeforeOpenInOneDrive subscribes to Table "Document Attachment" OnBeforeOpenInOneDrive
- DeleteAttachedDocumentsOnAfterDeleteExpense subscribes to Table "Expense" OnAfterDeleteEvent
- DeleteAttachedDocumentsOnAfterDeleteExpenseReportLine subscribes to Table "Expense Report Line" OnAfterDeleteEvent
- OnAfterGetRefTable subscribes to Codeunit "Document Attachment Mgmt" OnAfterGetRefTable
- OnAfterInitFieldsFromRecRef subscribes to Table "Document Attachment" OnAfterInitFieldsFromRecRef
- OnAfterSetDocumentAttachmentFiltersForRecRefInternal subscribes to Codeunit "Document Attachment Mgmt" OnAfterSetDocumentAttachmentFiltersForRecRefInternal
- OnAfterTableHasNumberFieldPrimaryKey subscribes to Codeunit "Document Attachment Mgmt" OnAfterTableHasNumberFieldPrimaryKey
- OnAfterTableHasLineNumberPrimaryKey subscribes to Codeunit "Document Attachment Mgmt" OnAfterTableHasLineNumberPrimaryKey
- OnCopyAttachmentsOnAfterSetFromParameters subscribes to Codeunit "Document Attachment Mgmt" OnCopyAttachmentsOnAfterSetFromParameters
- OnCopyAttachmentsOnAfterSetToParameters subscribes to Codeunit "Document Attachment Mgmt" OnCopyAttachmentsOnAfterSetToParameters
- OnCopyAttachmentsOnAfterSetToDocumentFilters subscribes to Codeunit "Document Attachment Mgmt" OnCopyAttachmentsOnAfterSetToDocumentFilters

## Procedures

- `RestrictAttachment(DocumentAttachment: Record "Document Attachment")` (internal)
- `HasPDFAttachment(TableID: Integer; DocumentNo: Code[20]; LineNo: Integer): Boolean` (internal)

Plus 11 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 1173 "Document Attachment Mgmt"](../codeunit/1173.md) (4 calls: `DeleteAttachedDocumentsOnAfterDeleteExpense → DeleteAttachedDocuments`, `DeleteAttachedDocumentsOnAfterDeleteExpenseReportLine → DeleteAttachedDocuments`, `UpdateReceiptAttachedOnExpense → AttachedDocumentsExist`, …)
- [Codeunit 4100 "Temp Blob"](../codeunit/4100.md) (2 calls: `UpdateContentHash → CreateInStream`, `UpdateContentHash → HasValue`)
- [Codeunit 6902 "Expense Rule Validation"](../codeunit/6902.md) (2 calls: `CheckAndUpdateAttachmentOnExpense → ValidateExpenseAgainstRule`, `CheckAndUpdateAttachmentOnExpenseReportLine → ValidateExpenseReportLineAgainstRule`)
- [Codeunit 1266 "Cryptography Management"](../codeunit/1266.md) (1 call: `UpdateContentHash → GenerateHash`)

## Called by

- [Codeunit 6952 "Exp. Attach. Buffer Handler"](../codeunit/6952.md) (1 call: `PropagateModifyAttachment → RestrictAttachment`)
- [Page 6988 "Expense"](../page/6988.md) (1 call: `OnAfterGetCurrRecord → HasPDFAttachment`)

## Recent changes

- 2026-09-15 [#10828 Avoid remote attachment checks during FactBox refresh](../../changes/bcapps/10828.md) (main, BC30, performance)
- 2026-08-04 [#9859 [Master] - Move Expense Agent (Preview) app into BCApps](../../changes/bcapps/9859.md) (main, BC30, feature, added)

## 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: "Expense Attachment Mgt.")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
