procedure CopyLinksFromEnquiriesToSalesL(rec_Enquiries: Record Enquiries)
var
SourceRecordLink: Record "Record Link";
rec_SalesHeader: Record "Sales Header";
textWorkDes: Text[500];
rec_notes: record Notes_temp;
RecordLink: Record "Record Link";
LinkManagement: Codeunit "Record Link Management";
LastEntryNo: Integer;
begin
rec_notes.DeleteAll();
if RecordLink.FindLast() then
LastEntryNo := RecordLink."Link ID"
else
LastEntryNo := 0;
SourceRecordLink.SetRange("Record ID", rec_Enquiries.RecordId);
if SourceRecordLink.FindSet() then
repeat
textWorkDes := GetWorkDescription(SourceRecordLink);
textWorkDes := DELSTR(textWorkDes, 1, 1);
rec_notes.Init();
rec_notes.No := CreateGuid();
rec_notes.Notes := textWorkDes;
rec_notes.Links := textWorkDes;
rec_notes."Record Id" := SourceRecordLink."Link ID";
rec_notes.Insert();
until SourceRecordLink.Next() = 0;
rec_SalesHeader.SetRange("No.", rec_Enquiries.No);
if rec_SalesHeader.FindSet() then begin
SourceRecordLink.SetRange("Record ID", rec_SalesHeader.RecordId);
if SourceRecordLink.FindSet() then
repeat
textWorkDes := GetWorkDescription(SourceRecordLink);
textWorkDes := DELSTR(textWorkDes, 1, 1);
rec_notes.SetRange(Links, textWorkDes);
if not rec_notes.FindSet() then begin
LastEntryNo := LastEntryNo + 1;
// rec_Enquiries.DeleteLinks();
RecordLink.Init();
RecordLink.Company := CompanyName();
RecordLink.Type := RecordLink.Type::Link;
RecordLink.Created := CurrentDateTime;
RecordLink."User ID" := UserId();
RecordLink."Link ID" := LastEntryNo;
RecordLink."Record ID" := rec_Enquiries.RecordId;
LinkManagement.WriteNote(RecordLink, textWorkDes);
RecordLink.Insert(true);
end;
until SourceRecordLink.Next() = 0;
end;
end;
procedure GetWorkDescription(SourceRecordLink: Record "Record Link") link: Text
var
MyInStream: InStream;
begin
Clear(link);
SourceRecordLink.Calcfields(Note);
If SourceRecordLink.Note.HasValue() then begin
SourceRecordLink.Note.CreateInStream(MyInStream);
MyInStream.Read(link);
end;
end;
I changed type to link, still getting blank.
Any additional changes is required in my code so that my link section also get copied?
Please help thankyou.