Used this recently to migrate notes which were added to a custom table first. Similar pattern would work for your scenario:
codeunit 90000 "Create Notes"
{
trigger OnRun()
var
NotesImport: Record "Notes Import";
Contact: Record Contact;
begin
GetLastEntryNo();
if NotesImport.FindSet() then
repeat
if Contact.Get(NotesImport."Contact No.") then begin
CreateSystemLink(Contact.RecordId, NotesImport.Note);
NotesImport.Delete();
end;
until NotesImport.Next() = 0;
end;
procedure CreateSystemLink(IncomingRecordID: RecordId; NoteText: Text)
var
RecordLink: Record "Record Link";
LinkManagement: Codeunit "Record Link Management";
begin
LastEntryNo += 1;
RecordLink.Init();
RecordLink.Company := CompanyName();
RecordLink.Type := RecordLink.Type::Note;
RecordLink.Created := CurrentDateTime;
RecordLink."User ID" := UserId();
RecordLink."Link ID" := LastEntryNo;
RecordLink."Record ID" := IncomingRecordID;
LinkManagement.WriteNote(RecordLink, NoteText);
RecordLink.Insert(true);
end;
procedure GetLastEntryNo()
var
RecordLink: Record "Record Link";
begin
if RecordLink.FindLast() then
LastEntryNo := RecordLink."Link ID"
else
LastEntryNo := 0;
end;
var
LastEntryNo: Integer;
}