Attachments are files that you can link to entities or documents in Dynamics 365 Business Central. Two main tables are used to store attachments:
- Document attachment (ID = 1173)
- Attachment (ID = 5062)
To store an attachment in these tables and then download an attachment from these tables, you need to use the previously mentioned UploadIntoStream and DownloadFromStream methods and load the BLOB field by using Streams.
An example of a function that uploads a file to the Attachment table is as follows:
procedure UploadAttachment()
var
Attachment: Record Attachment;
outStr: OutStream;
inStr: InStream;
tempfilename: text;
FileMgt: Codeunit "File Management";
DialogTitle: Label 'Please select a File...';
begin
if UploadIntoStream(DialogTitle, '', 'All Files (*.*)|*.*&apos...