logo
search
Others

How to Copy Attachments Between Business Central Tables Using AL

Adam DavisAdam Davis Sep 28, 2026 869 views

Question details

The user needs to copy attachment files from one table to another within Microsoft Dynamics 365 Business Central.

How to Copy Attachments Between Business Central Tables Using AL
Product
Microsoft Dynamics 365 Business Central
Device & OS
not provided
Scenario
Developing or customizing a Business Central application where documents or attachments must be transferred between different records.
Observed behavior
Requires Business Central-specific AL development APIs and methods to properly copy file content and metadata, which cannot be achieved through standard end-user UI or Microsoft Access.
Before you start

Ensure you have access to a Dynamics 365 Business Central sandbox environment, Visual Studio Code with the AL Language extension installed, and developer permissions to modify table data.

Solution 1Recommended

Use AL Streams and the Document Attachment Table

Write a custom AL procedure to read the BLOB data from the source attachment record using an InStream, and write it to the destination record using an OutStream.

Business Central attachments are typically stored in the 'Document Attachment' table (Table 1173). Transferring these files requires handling BLOB data via AL stream methods rather than simply copying standard text fields.

Since this is a development-heavy task, complex implementations should be discussed in the official Dynamics 365 Business Central community forums.

1
Identify the source and destination records

Declare your record variables in AL for the 'Document Attachment' table. Filter the source record using SetRange to match the specific 'Table ID' and 'No.' of your source document.

2
Initialize InStream and OutStream

Create variables for InStream and OutStream. Use the 'CreateInStream' method on the source attachment's BLOB field to prepare the data for reading.

3
Transfer the BLOB data

Initialize a new record for the destination table. Use the 'CreateOutStream' method on the destination's BLOB field, and then use the 'CopyStream' function to transfer the data from the InStream to the OutStream.

4
Insert the new attachment record

Populate the required metadata fields (such as File Name, File Extension, and destination Table ID) on the new record, and execute the 'Insert(true)' command to save the attachment to the database.

5
Seek specialized assistance

If you encounter errors with temporary tables or tenant media handling, post your specific AL code snippet in the Dynamics Community forum for expert peer review.

Use AL Streams and the Document Attachment Table
Development Resources: This procedure falls strictly under Dynamics 365 Business Central AL development and cannot be executed using Microsoft Access or standard Office applications.
Free Microsoft Office alternative

Manage Your Exported Business Reports with WPS Office

While Dynamics 365 Business Central handles your enterprise resource planning and AL database structures, you'll often need a reliable office suite to view, edit, and share the spreadsheets and document attachments exported from your ERP. WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office for managing all your daily business files.

Completely free and lightweight office suite for seamless daily workflowHighly compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint formatsEasily view and analyze financial reports and data exports from Business CentralFamiliar user interface ensuring zero learning curve and seamless migration
microsoft office alternative - wps office

Frequently Asked Questions

Which table stores attachments in Dynamics 365 Business Central?

In modern versions of Dynamics 365 Business Central, attachments are typically stored in the 'Document Attachment' table (Table 1173), replacing older methods that stored BLOBs directly on transactional records.

Can I use Microsoft Access to copy these attachments?

No. Copying attachments between Business Central tables requires AL development, stream handling, and specific APIs. Microsoft Access cannot execute AL code or properly handle Business Central's internal BLOB and media data structures.

Where can I find AL code examples for handling BLOBs and streams?

You can find specialized AL development documentation on the Microsoft Learn portal under the Dynamics 365 Business Central developer guides, or by visiting the Dynamics 365 Community forums where developers share code snippets.