web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Adding attahcments to documents in Business central, using API

(0) ShareShare
ReportReport
Posted on by 37
I want to add attahcment to the posted sales shipment card, I used 2 tables "Document Attachment", and "Attahcment Entity Buffer", but no success.
 
Can someone guide me or have a step by step tutorial link you can send me,.
 
I watched this video https://www.youtube.com/watch?v=hEVjHlAgfbU but I didn't get the same result.
 
Here are the apis i created : 
page 50818 "Document Attachment DetailsAPI"
{
    PageType = API;

    APIVersion = 'v1.0';
    APIPublisher = 'bctech';
    APIGroup = 'demo';
    EntityCaption = 'documentAttachmentDetailsAPI';
    EntitySetCaption = 'documentAttachmentDetailsAPI';
    EntityName = 'documentAttachmentDetailsAPI';
    EntitySetName = 'documentAttachmentDetailsAPI';
    SourceTable = "Document Attachment";
    Extensible = false;
    DelayedInsert = true;
    InsertAllowed = true;

    layout
    {
        area(Content)
        {
            repeater(General)
            {
                field(documentType; Rec."Document Type")
                {
                    Caption = 'Document Type';
                }
                field(fileName; Rec."File Name")
                {
                    Caption = 'Attachment';
                }
                field(fileType; Rec."File Type")
                {
                    Caption = 'File Type';
                }
                field(documentReferenceID; Rec."Document Reference ID")
                {
                    Caption = 'Document Reference ID';
                }
                field(attachedDate; Rec."Attached Date")
                {
                    Caption = 'Attached Date';
                }
                field(id; Rec.ID)
                {
                    Caption = 'ID';
                }
                field(lineNo; Rec."Line No.")
                {
                    Caption = 'Line No.';
                }
                field(no; Rec."No.")
                {
                    Caption = 'No.';
                }
                field(fileExtension; Rec."File Extension")
                {
                    Caption = 'File Extension';
                }
                field(tableID; Rec."Table ID")
                {
                    Caption = 'Table ID';
                }
            }
        }
    }
}
page 50831 AttachmentBuffer
{
    APIGroup = 'demo';
    APIPublisher = 'bctech';
    APIVersion = 'v1.0';
    ApplicationArea = All;
    Caption = 'attachmentBuffer';
    DelayedInsert = true;
    EntityName = 'AttachmentBuffer';
    EntitySetName = 'AttachmentBuffer';
    PageType = API;
    SourceTable = "Attachment Entity Buffer";
    InsertAllowed = true;
    ModifyAllowed = true;

    layout
    {
        area(Content)
        {
            repeater(General)
            {
                field(id; Rec.Id)
                {
                    Caption = 'Id';
                }
                field(fileName; Rec."File Name")
                {
                    Caption = 'File Name';
                }
                field("type"; Rec."Type")
                {
                    Caption = 'Type';
                }
                field(attachmentContent; Rec.Content)
                {
                    Caption = 'Content';
                }
                field(documentType; Rec."Document Type")
                {
                    Caption = 'Document Type';
                }
                field(parentType; Rec."Attachment Type")
                {
                    Caption = 'Attachment Type';
                }
                field(parentId; Rec."Document Id")
                {
                    Caption = 'Document Id';
                    ShowMandatory = true;

                    trigger OnValidate()
                    begin
                        
                    end;
                }
                field(lineNo; Rec."Line No.")
                {
                    Caption = 'Line No.';
                }
                field(systemId; Rec.SystemId)
                {
                    Caption = 'SystemId';
                }
            }
        }
    }
}
 
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,175

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,476 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,435 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans