---
id: object/table/1173
type: object
title: Table 1173 "Document Attachment"
summary: Table 1173 "Document Attachment" in Base Application (Microsoft.Foundation.Attachment). 17 fields, 23 public procedures, 18 events. Present since at least BC23, still in BC30, changed in BC24-26, BC29.
tier: official
language: en
tags:
  - table
  - base application
versions:
  introduced: null
  last_changed: "29"
  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: 4f0170905b5aad91cbfb1fb26e3e095b36d35fcd4fbb3318bffdfeec327c2191
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Foundation/Attachment/DocumentAttachment.Table.al
    title: src/Layers/W1/BaseApp/Foundation/Attachment/DocumentAttachment.Table.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: table
object_id: 1173
name: Document Attachment
namespace: Microsoft.Foundation.Attachment
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "26"
  - "29"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 17
  procedures: 46
  events: 18
  subscribers: 0
relations:
  out: 1
  referenced_by: 3
  pages: 4
  extended_by: 3
  event_subscribers: 20
  calls: 5
  called_by: 0
  implements: 0
---

# Table 1173 "Document Attachment"

> Table 1173 "Document Attachment" in Base Application (Microsoft.Foundation.Attachment). 17 fields, 23 public procedures, 18 events. Present since at least BC23, still in BC30, changed in BC24-26, BC29.

Base Application · Microsoft.Foundation.Attachment · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Foundation/Attachment/DocumentAttachment.Table.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Caption | Document Attachment |
| DataClassification | CustomerContent |

## Fields

Explanation: the field's ToolTip in the code; without one, the ToolTip of a page control bound to the field (marked via the page); without that, its Caption (marked caption) when that differs from the name.

| No. | Name | Type | Explanation | Notes |
|---|---|---|---|---|
| 1 | ID | Integer | — | not editable; AutoIncrement |
| 2 | Table ID | Integer | Specifies the table ID the attachment belongs to. <small>via [Page 8751 "Document Attachment - External"](../page/8751.md)</small> | TableRelation AllObjWithCaption."Object ID" where("Object Type" = const(Table)); NotBlank |
| 3 | No. | Code[20] | Specifies the record number the attachment belongs to. <small>via [Page 8751 "Document Attachment - External"](../page/8751.md)</small> | NotBlank |
| 4 | Attached Date | DateTime | Specifies the date when the document was attached. |  |
| 5 | File Name | Text[250] | Specifies the filename of the attachment. | NotBlank |
| 6 | File Type | Enum "Document Attachment File Type" | Specifies the type of document that the attachment is. | enum [Enum 1174 "Document Attachment File Type"](../enum/1174.md) |
| 7 | File Extension | Text[30] | Specifies the file extension of the attachment. |  |
| 8 | Document Reference ID | Media | — |  |
| 9 | Attached By | Guid | Specifies the user who attached the file. <small>via [Page 8751 "Document Attachment - External"](../page/8751.md)</small> | TableRelation User."User Security ID" where("License Type" = const("Full User")); not editable |
| 10 | User | Code[50] | Specifies the user who attached the document. | FlowField: lookup(User."User Name" where("User Security ID" = field("Attached By"), "License Type" = const("Full User"))); not editable |
| 11 | Document Flow Purchase | Boolean | Specifies if the attachment must flow to transactions. |  |
| 12 | Document Flow Sales | Boolean | Specifies if the attachment must flow to transactions. |  |
| 13 | Document Type | Enum "Attachment Document Type" | — | enum [Enum 1173 "Attachment Document Type"](../enum/1173.md) |
| 14 | Line No. | Integer | — |  |
| 15 | VAT Report Config. Code | Enum "VAT Report Configuration" | — | TableRelation [Table 746 "VAT Reports Configuration"](../table/746.md) ("VAT Reports Configuration"."VAT Report Type"); enum [Enum 740 "VAT Report Configuration"](../enum/740.md) |
| 20 | Document Flow Service | Boolean | Specifies if the attachment must flow to transactions. |  |
| 21 | Document Flow Production | Boolean | Specifies if the attachment must flow to transactions. |  |

## Keys

- Key1: Table ID, No., Document Type, Line No., ID (clustered)
- Key2: Document Reference ID

## Events published

- `OnBeforeHasContent(var DocumentAttachment: Record "Document Attachment"; var AttachmentIsAvailable: Boolean; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) DocumentAttachment_OnBeforeHasContent
- `OnBeforeImportFromStream(var DocumentAttachment: Record "Document Attachment"; var AttachmentInStream: InStream; var FileName: Text; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 6989 "Expense Attachment Mgt."](../codeunit/6989.md) OnBeforeImportFromStream
- `OnBeforeExportToStream(var DocumentAttachment: Record "Document Attachment"; var AttachmentOutStream: OutStream; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) DocumentAttachment_OnBeforeExportToStream
- `OnBeforeGetAsTempBlob(var DocumentAttachment: Record "Document Attachment"; var TempBlob: Codeunit "Temp Blob"; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) DocumentAttachment_OnBeforeGetAsTempBlob
- `OnBeforeOpenInOneDrive(var Rec: Record "Document Attachment"; DocumentSharingIntent: Enum "Document Sharing Intent"; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 6989 "Expense Attachment Mgt."](../codeunit/6989.md) OnBeforeOpenInOneDrive, [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) Document Attachment_OnBeforeOpenInOneDrive
- `OnBeforeGetContentType(var Rec: Record "Document Attachment"; var ContentType: Text[100]; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) DocumentAttachment_OnBeforeGetContentType
- `OnBeforeExport(var DocumentAttachment: Record "Document Attachment"; var IsHandled: Boolean; ShowFileDialog: Boolean)` (integration)
- `OnBeforeExportAttachment(var DocumentAttachment: Record "Document Attachment")` (integration)
- `OnBeforeInsertAttachment(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef)` (integration)
  - subscribers: [Codeunit 20414 "Qlty. Attachment Integration"](../codeunit/20414.md) HandleOnBeforeInsertAttachment, [Codeunit 6169 "E-Doc. Attachment Processor"](../codeunit/6169.md) OnBeforeInsertAttachmentForEDocs
- `OnBeforeSaveAttachment(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef; var FileName: Text; var TempBlob: Codeunit "Temp Blob")` (integration)
- `OnBeforeSaveAttachmentFromStream(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef; var FileName: Text; var DocStream: InStream)` (integration)
- `OnAfterInitFieldsFromRecRef(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef)` (integration)
  - subscribers: [Codeunit 6989 "Expense Attachment Mgt."](../codeunit/6989.md) OnAfterInitFieldsFromRecRef, [Codeunit 8059 "Sub. Contracts General Mgt."](../codeunit/8059.md) InitDocumentAttachmentFields
- `OnBeforeValidateDocumentFlowPurchase(var DocumentAttachment: Record "Document Attachment"; xDocumentAttachment: Record "Document Attachment"; var IsHandled: Boolean)` (integration)
- `OnBeforeValidateDocumentFlowSales(var DocumentAttachment: Record "Document Attachment"; xDocumentAttachment: Record "Document Attachment"; var IsHandled: Boolean)` (integration)
- `OnBeforeValidateDocumentFlowService(var DocumentAttachment: Record "Document Attachment"; xDocumentAttachment: Record "Document Attachment"; var IsHandled: Boolean)` (integration)
- `OnInsertOnBeforeCheckDocRefID(var DocumentAttachment: Record "Document Attachment"; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 6907 "Expense Doc. Att. Subscribers"](../codeunit/6907.md) OnInsertOnBeforeCheckDocRefID, [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) Document Attachment_OnInsertOnBeforeCheckDocRefID
- `OnInsertAttachmentOnBeforeImportStream(var DocumentAttachment: Record "Document Attachment"; DocInStream: InStream; FileName: Text; var IsHandled: Boolean)` (integration)
- `OnAfterIsPostedDocument(TableID: Integer; var Posted: Boolean)` (integration)
  - subscribers: [Codeunit 6459 "Serv. Document Attachment Mgt."](../codeunit/6459.md) OnInsertOrderTrackingEntry

## Trigger event subscribers

- OnAfterDeleteEvent: [Codeunit 6989 "Expense Attachment Mgt."](../codeunit/6989.md) OnAfterDeleteEvent, [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) OnAfterDeleteDocumentAttachment
- OnAfterInsertEvent: [Codeunit 6989 "Expense Attachment Mgt."](../codeunit/6989.md) OnAfterInsertEvent, [Codeunit 8751 "DA External Storage Impl."](../codeunit/8751.md) OnAfterInsertDocumentAttachment
- OnAfterModifyEvent: [Codeunit 6989 "Expense Attachment Mgt."](../codeunit/6989.md) OnAfterModifyEvent
- OnBeforeDeleteEvent: [Codeunit 6989 "Expense Attachment Mgt."](../codeunit/6989.md) OnBeforeDeleteAttachment

## Procedures

- `ImportAttachment(DocumentInStream: InStream; FileName: Text)`
- `Export(ShowFileDialog: Boolean): Text`
- `HasPostedDocumentAttachment(Record: Variant): Boolean`
- `SupportedByFileViewer(): Boolean`
- `SaveAttachment(RecRef: RecordRef; FileName: Text; TempBlob: Codeunit "Temp Blob")`
- `SaveAttachment(RecRef: RecordRef; FileName: Text; TempBlob: Codeunit "Temp Blob"; AllowDuplicateFileName: Boolean)`
- `SaveAttachment(Files: List of [FileUpload]; RecRef: RecordRef)`
- `SaveAttachment(Files: List of [FileUpload]; RecRef: RecordRef; EncodingType: TextEncoding)`
- `SaveAttachmentFromStream(DocStream: InStream; RecRef: RecordRef; FileName: Text)`
- `SaveAttachmentFromStream(DocStream: InStream; RecRef: RecordRef; FileName: Text; AllowDuplicateFileName: Boolean)`
- `InitFieldsFromRecRef(RecRef: RecordRef)`
- `FindUniqueFileName(FileName: Text; FileExtension: Text): Text[250]`
- `VATReturnSubmissionAttachmentsExist(VATReportHeader: Record "VAT Report Header"): Boolean`
- `VATReturnResponseAttachmentsExist(VATReportHeader: Record "VAT Report Header"): Boolean`
- `DownloadZipFileWithVATReturnSubmissionAttachments(VATRepConfigCode: Enum "VAT Report Configuration"; VATReportNo: Code[20]): Boolean`
- `DownloadZipFileWithVATReturnResponseAttachments(VATRepConfigCode: Enum "VAT Report Configuration"; VATReportNo: Code[20]): Boolean`
- `HasContent(): Boolean`
- `ImportFromStream(AttachmentInStream: InStream; FileName: Text)`
- `ExportToStream(var AttachmentOutStream: OutStream)`
- `GetAsTempBlob(var TempBlob: Codeunit "Temp Blob")`
- `GetContentType(): Text[100]`
- `ViewFile()`
- `OpenInOneDrive(DocumentSharingIntent: Enum "Document Sharing Intent")`

Plus 5 local procedures.

## Triggers

OnInsert

## Relations

- VAT Report Config. Code: TableRelation [Table 746 "VAT Reports Configuration"](../table/746.md)

## Referenced by

3 fields in 3 objects relate to this table (TableRelation or CalcFormula).

- [Table 37 "Sales Line"](../table/37.md): Attached Doc Count
- [Table 39 "Purchase Line"](../table/39.md): Attached Doc Count
- [Table 8750 "DA External Storage Setup"](../table/8750.md): Has Uploaded Files

## Pages and codeunits on this table

- [Page 1173 "Document Attachment Details"](../page/1173.md) (source table)
- [Page 1178 "Doc. Attachment List Factbox"](../page/1178.md) (source table)
- [Page 6956 "Expense Picture"](../page/6956.md) (source table)
- [Page 8751 "Document Attachment - External"](../page/8751.md) (source table)

## Extended by

- [Table extension 6160 "E-Doc. Attachment"](../tableextension/6160.md)
- [Table extension 6902 "Exp. Document Attachment Ext"](../tableextension/6902.md)
- [Table extension 8750 "Document Attachment Ext.Stor."](../tableextension/8750.md)

## 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) (8 calls: `FindUniqueFileName → IsDuplicateFile`, `InitFieldsFromRecRef → TableHasDocTypePrimaryKey`, `InitFieldsFromRecRef → TableHasLineNumberPrimaryKey`, …)
- [Codeunit 419 "File Management"](../codeunit/419.md) (6 calls: `Export → BLOBExport`, `InsertAttachment → GetExtension`, `InsertAttachment → GetFileNameWithoutExtension`, …)
- [Codeunit 4100 "Temp Blob"](../codeunit/4100.md) (5 calls: `DownloadZipFileWithVATReturnAttachments → CreateInStream`, `DownloadZipFileWithVATReturnAttachments → CreateOutStream`, `Export → CreateOutStream`, …)
- [Codeunit 425 "Data Compression"](../codeunit/425.md) (4 calls: `DownloadZipFileWithVATReturnAttachments → AddEntry`, `DownloadZipFileWithVATReturnAttachments → CloseZipArchive`, `DownloadZipFileWithVATReturnAttachments → CreateZipArchive`, …)
- [Codeunit 9510 "Document Service Management"](../codeunit/9510.md) (3 calls: `OpenInOneDrive → EditInOneDriveFromMedia`, `OpenInOneDrive → OpenInOneDriveFromMedia`, `OpenInOneDrive → ShareWithOneDriveFromMedia`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-26, BC29

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: "table", object_name: "Document Attachment")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
