Email this post as a PDFDevelopment · 6 October 2026 · 2 min read

Document attachments, Media fields and where files should live

Users attach PDFs to customers and orders every day. Extensions that store files have three choices: the standard Document Attachment table, a Media or MediaSet field, or a Blob. Which to use, how to add the standard attachment FactBox to your own table, copying attachments to posted documents, and keeping the database from filling with scans.

Contents
  1. The three options
  2. Using Document Attachment on your own table
  3. Copying to posted documents
  4. Media fields in practice
  5. Storage discipline

Business Central stores files in three ways, and the right one depends on who looks at them and how often. Getting it wrong means either a database that grows by gigabytes a month or an integration that cannot find the file it needs.

The three options

Document AttachmentMedia / MediaSet fieldBlob field
What it isThe standard table (1173) linking any record to any number of files, with the FactBox users already knowA field type for images and files, stored in platform media storage, deduplicated, streamed to the clientA binary column on your table
Use forUser-managed documents on master data and documents: contracts, certificates, scansPictures (item images, logos) and files your code displays or returns through an APISmall generated content read only by code (a cached payload, a signature)
Visible in clientAttachments FactBox, drill-down, downloadImage controls; download via codeNot directly
Counts toward storageYes (database)Yes (media storage, reported separately)Yes (database)

Using Document Attachment on your own table

The standard FactBox works on any table once you tell it how to link. Add the "Document Attachment Factbox" part to your card and list with SubPageLink on your table ID and primary key; subscribe to OnAfterInitFieldsFromRecRef in Codeunit "Document Attachment Mgmt" (or the newer OnBeforeInsertAttachment events) to map your record's key fields into the attachment's "No." / "Line No.". Users then attach, view and delete through the standard UI, and the files are in the standard place for backups, retention and GDPR requests.

Copying to posted documents

The base application copies attachments from a sales order to the posted shipment and invoice by subscribing to the posting events and calling DocumentAttachmentMgmt.CopyAttachments. If your extension posts its own document, do the same from your posting routine.

Media fields in practice

field(50120; "CON Label"; Media) { Caption = 'Label'; }
// store
Shipment."CON Label".ImportStream(InStr, FileName);
// read back
Shipment."CON Label".ExportStream(OutStr);
// has one?
if Shipment."CON Label".HasValue() then ...

MediaSet holds several; Picture on Item is a MediaSet. Media is deduplicated by content, so ten records with the same logo store it once.

Storage discipline

  • Scans of every delivery note for ten years do not belong in the ERP database. Store them in SharePoint or blob storage and keep a link (the Record Link table, or a URL field) in Business Central. The storage allowance is finite and overage is charged.
  • Apply a retention policy to attachments on posted documents older than the business needs (retention post).
  • Watch the Capacity page in the admin centre; media and attachments are usually the two biggest lines after ledger entries.
Email this post as a PDF
A branded PDF of this post, sent to your inbox to keep, print or share. Copy in colleagues if you like.
We only use these addresses to send this PDF. Nobody is added to a mailing list. Mike at Business Boxed receives a copy. See our privacy notice.
Email this post
Talk to us
Want this done in your Business Central?
Book a 30 minute callGet the monthly newsletter

Related posts