If you have scenarios where you need to copy document links from one record to another (For example, as part of a posting routine) then you may require some additional code.
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. |