Skip to main content

Notifications

Small and medium business | Business Central, N...
Unanswered

How to copy Links section in business central?

Posted on by 200

When I copy links from sales order to enquiry card link section is coming blank?

I used this code:

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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,134 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans