27 Mar’19

D365 Business CentralHow to Attach Documents to any Record of any Table in Business Central

Introduction:

Attachment is a relatively new functionality in Business Central. Unlike Links you need not store the links to the document but attach the document itself. In this blog I’ll be showing how to customize Business Central to attach documents to any table.

Pre-requisite:

VS Code
Microsoft Dynamics Business Central

Demonstration:

Attachments are stored in Table 1173 Document Attachment Table. Using the standard document attachment table functionality does not support attaching on all the tables / pages. Currently in Business Central attachment functionality is allowed only on Master and Documents.

  • Adding a field in Document Attachment Table to classify if you want to attach documents for different purpose. In this case I wanted to Attach two types of Documents. So I created an Option Type with Scale Ticket and Lab Report which will be set during the insertion of attachment in the Page. Refer: SaveAttachment2 function.

 

 

 

 

 

 

  • Creating a Custom page with Source table as Table 1173 Attachment Document. I’ve created a Custom Page because the standard pages calls a function that does not allow me to attach different types of attachment. Thus the Custom page contains SaveAttachment2 function which allows to mention the type of Attachment for the record.

  • Adding Custom methods to Attach the documents with different types on Single Record.
    i.) Export : This function downloads the attachment that is stored in the system wen clicked on the name

 

 

 

 

 

 

ii.) SaveAttachment2:This function saves the attachment for the record with the specific type of attachment. It stores the TableID, Record Primary Key and then LoadType to specify type of attachment for that load.

GetLoadType: This function is used to pass the type

 

 

 

 

Calling the CustomAttachedPage from the Page/ Table you want to attach.

 

 

 

 

 

 

 

 

 

Output:

From the Record you want to attach the document

 

To download the Attachment, click on the Attachment FileName.

Conclusion:

In this way we can attach documents to any record of any table in Business Central.

Written by

Olister Rumao

Software Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Expenses in PSA for Fixed Bid and T&M contracts

    23 August’ 2019

    Problem Definition: One of my clients decided to use Expense module in PSA and to his surprise he could see the amount v...

    Read more
  • Setup Dockers

    23 August’ 2019

    Docker is an independent container platform that enables organizations to seamlessly build, share and run any applicatio...

    Read more
  • Qualify Lead in D365 CE: Select which entity records should be created

    20 August’ 2019

    Wave 2019 Updates brought some really sought-after features. Another one which I would like to bring up is the Lead Qual...

    Read more
  • Early Opt-in for October 2019 Wave 2 Updates

    20 August’ 2019

    August 2, 2019 was when the Wave 2 Updates were to be out. And here we are! By now, you should have gotten the option to...

    Read more
  • Setting Unified Interface App Icons

    20 August’ 2019

    Default App Icons for typical D365 environment look like these.But here’s what you can do to change these to put...

    Read more
  • We respect your privacy.
  • This field is for validation purposes and should be left unchanged.