How to add Clever Document Links to your custom tables

How to add Clever Document Links to your custom tables

We often get asked if you can add Clever Document Links to your custom tables and yes, it’s incredibly easy. Just follow these steps in your extension.

Step 1. Add a dependency

Add a dependency to Clever Document Links in the app.json file of your extension as follows:

You can cut and paste the text from here, just don’t forget the comma after the base application entry.

      "name": "Base Application",
      "version": "16.0.0.0"
    },
    {
      "id": "a7359d55-e70d-488d-8fc9-0b5cef655f6e",
      "publisher": "Clever Dynamics",
      "name": "Clever Document Links",
      "version": "1.2.9.5393"
    }
  ],

Step 2. Download symbols

Next download your symbols, you should see that succeed, see the text below in your output area and result in an extra file in your .alpackages folder.

[2020-05-01 10:00:08.29] Sending request to https://api.businesscentral.dynamics.com/v1.0/sandbox/dev/packages?publisher=Clever Dynamics&appName=Clever Document Links&versionText=1.2.9.5393
[2020-05-01 10:01:30.78] The following dependencies will be queried for propagated dependencies:
Clever Config by Clever Dynamics (1.0.8.1)
[2020-05-01 10:01:30.78] Sending request to https://api.businesscentral.dynamics.com/v1.0/sandbox/dev/packages?publisher=Clever Dynamics&appName=Clever Config&versionText=1.0.8.1

Step 3. Add your page extension

Then add to your page extension the following code to add the Document Links Factbox:

addfirst(FactBoxes)
{
    part(DLFileDropFactboxCDLTMN; "DL File Drop Factbox CDLTMN")
    {
    ApplicationArea = All;
    }
}

Step 4. Finishing up

Add the following line to the OnAfterGetRecord trigger:

trigger OnAfterGetCurrRecord()
    begin
        CurrPage.DLFileDropFactboxCDLTMN.Page.SetDocumentRecordID(RecordId());
    end;

All done!

So, two small additions of effectively one line each and you can drag and drop against any of your custom records and ones where we haven’t added the Factbox.

You can find sample code for both adding via a page extension and to a custom table on my Github repository.