Adding Document Links to a Custom Page

It really simple to add Clever Document Links functionality to either your own custom pages or a page extension to the standard application for one of the few pages we haven’t put it on.

  1. Create Dependency in the app.json of your app on Clever Document Links

    "dependencies": [

    {

    "id": "a7359d55-e70d-488d-8fc9-0b5cef655f6e",

    "publisher": "Clever Dynamics",

    "name": "Clever Document Links",

    "version": "1.2.9.5393"

    }

    ]

  2. Add a factbox to the page or page extension as follows

part(DLFileDropFactboxCDLTMN; "DL File Drop Factbox CDLTMN")

{

ApplicationArea = All;

}

  1. Add the following line to or create a OnAfterGetCurrRecord trigger as follows

    trigger OnAfterGetCurrRecord()

    begin

    CurrPage.DLFileDropFactboxCDLTMN.Page.SetDocumentRecordID(RecordId());

    end;

    And your done, nothing more to it than that.

codeunit "Document Links Mgt. CDLTMN" has the following functions to manage Document Links against a record.

  • CopyDocumentLinks(FromRecordID: RecordID; ToRecordID: RecordID)

    • This function will copy any existing document links from a given record to another.

      • FromRecordID – Record ID of the source record

      • ToRecordID – Record ID of the destination record

  • DeleteDocumentLinks(RecRef: RecordRef; RunTrigger: Boolean)

    • This function will delete any document links for a given record

      • RecRef – Record Ref of the source record

      • RunTrigger – will attempt to delete the Linked Documents record, including the files from the storage location, if there are no other links to the file.

  • RenameDocumentLinks(RecRef: RecordRef; xRecRef: RecordRef)

    • This function will copy the document links to a new record and then remove the links against the original record.

      • RecRef – Record Ref of the new record

      • xRecRef - Record Ref of the original record

Note: To support rename or deletion of records from business central, both RenameDocumentLinks and DeleteDocumentLinks are invoked within the product from GlobalTriggerManagment through subscribing to events OnAfterOnDatabaseRename and OnAfterOnDatabaseDelete