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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Document Attachment not uploading files

(6) ShareShare
ReportReport
Posted on by 175
I have created a document attachment fact box for my custom page.
 
I have copied similer code of what is in job card page attachment facboxes. Hovever i am getting following error when i attach a document.
 
 
 
 
 
 
 
 
 
 
 
 
how can i resolve the issue?
 
 
 
 
I have the same question (0)
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,424 Super User 2026 Season 1 on at
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,424 Super User 2026 Season 1 on at
  • Suggested answer
    GM-01091622-0 Profile Picture
    10 on at

    if you copied the Job Card attachments factbox 1:1, the upload error is usually one of two things:

    1) Using the old factbox.

    The classic “Document Attachment FactBox” is obsolete now. Swap it for “Doc. Attachment List Factbox” on your custom page. That alone fixed it for me. (MS Learn notes the old one is being replaced.) 

    2) The link isn’t pointing to your record correctly.

    Make sure the factbox has a proper SubPageLink to your table and the key the attachment framework expects. For a simple header with a No. key it’s basically:

    area(FactBoxes)
    {
    part(Attachments; "Doc. Attachment List Factbox")
    {
    ApplicationArea = All;
    SubPageLink = "Table ID" = const(Database::"My Custom Header"),
    "No." = field("No.");
    }
    }

    If your table doesn’t use a field literally named No. (e.g., GUID or different PK), you need to map that key so the factbox can resolve the record. Easiest path is to expose a No.-style field that represents your key, or handle the record ref in an event subscriber (lots of folks do this in custom pages). A quick community thread + walkthrough here helps show the pattern. 

    Good refs (short + practical):

  • Suggested answer
    Suresh Kulla Profile Picture
    50,278 Super User 2026 Season 1 on at
    The Document Attachment feature is not active or supported for every table; you need to customize the subscription to events to make the upload work.
     
    You need to subscribe to the events in Document Attachemnt Table, Page, and Factbox. See an example below
     
  • Suggested answer
    YUN ZHU Profile Picture
    101,022 Super User 2026 Season 1 on at
    This is a little more complicated than you might think, so hopefully the following examples will give you some hints.
    How to add Attachments, Links, Notes Factbox to any pages
     
    Thanks.
    ZHU
  • Aakib khan Profile Picture
    128 on at
    Try to use this demo code in your code:

    pageextension 50117 VendorBankAccountCard extends "Vendor Bank Account Card"
    {
        actions
        {
            addfirst(Processing)
            {
                action(DocAttach)
                {
                    ApplicationArea = All;
                    Caption = 'Attachments';
                    Image = Attach;
                    ToolTip = 'Add a file as an attachment. You can attach images as well as documents.';
                    trigger OnAction()
                    var
                        DocumentAttachmentDetails: Page "Document Attachment Details";
                        RecRef: RecordRef;
                    begin
                        RecRef.GetTable(Rec);
                        DocumentAttachmentDetails.OpenForRecRef(RecRef);
                        DocumentAttachmentDetails.RunModal();
                    end;
                }
            }
        }
    }
    codeunit 50117 DocumentAttachment2
    {
        [EventSubscriber(ObjectType::Page, Page::"Document Attachment Factbox", 'OnBeforeDrillDown', '', false, false)]
        local procedure OnBeforeDrillDown(DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef);
        var
            VendorBankAccount: Record "Vendor Bank Account";
        begin
            case DocumentAttachment."Table ID" of
                DATABASE::"Vendor Bank Account":
                    begin
                        RecRef.Open(DATABASE::"Vendor Bank Account");
                        if VendorBankAccount.Get(DocumentAttachment."No.") then
                            RecRef.GetTable(VendorBankAccount);
                    end;
            end;
        end;
        [EventSubscriber(ObjectType::Page, Page::"Document Attachment Details", 'OnAfterOpenForRecRef', '', false, false)]
        local procedure OnAfterOpenForRecRef(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef; var FlowFieldsEditable: Boolean);
        var
            FieldRef: FieldRef;
            RecNo: Code[20];
            VendorBankCode: Code[20];
        begin
            case RecRef.Number of
                DATABASE::"Vendor Bank Account":
                    begin
                        FieldRef := RecRef.Field(1);
                        RecNo := FieldRef.Value;
                        DocumentAttachment.SetRange("No.", RecNo);
                        FieldRef := RecRef.Field(2);
                        VendorBankCode := FieldRef.Value;
                        DocumentAttachment.SetRange("Vendor Bank Number", VendorBankCode);
                        FlowFieldsEditable := false;
                    end;
            end;
        end;
        [EventSubscriber(ObjectType::Table, Database::"Document Attachment", 'OnAfterInitFieldsFromRecRef', '', false, false)]
        local procedure OnAfterInitFieldsFromRecRef(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef)
        var
            FieldRef: FieldRef;
            RecNo: Code[20];
            VendorBankCode: Code[20];
        begin
            case RecRef.Number of
                DATABASE::"Vendor Bank Account":
                    begin
                        FieldRef := RecRef.Field(1);
                        RecNo := FieldRef.Value;
                        DocumentAttachment.Validate("No.", RecNo);
                        FieldRef := RecRef.Field(2);
                        VendorBankCode := FieldRef.Value;
                        DocumentAttachment.Validate("Vendor Bank Number", VendorBankCode);
                    end;
            end;
        end;
    }
    tableextension 50100 DocumentAttachmentExt extends "Document Attachment"
    {
        fields
        {
            field(50100; "Vendor Bank Number"; Code[20])
            {
                DataClassification = CustomerContent;
            }
        }
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,029 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,226 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,201

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans