web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Copy my notes from sales order to Enquiry and enquiry to sales

(0) ShareShare
ReportReport
Posted on by 208

1682524681134_5F00_reclink-screenshot.png

Here this is my code to copy my notes from sales order to enquire card, but I want to copy my notes from enquiry card to sales order vise versa .. 

So how it can be done.

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Show your complete code.

  • Dividutt Profile Picture
    208 on at

    This is my code;

    procedure InsertEnquiriesHeader()

       var

           recEnquiries: Record Enquiries;

           rec_SalesHeader: Record "Sales Header";

           rec_SalesHeaderArchive: Record "Sales Header Archive";

           enumSalesDocType: Enum "Sales Document Type";

           recEnquiriesLine: Record "Enquiries Line";

           versionNo: Integer;

           recordlink: Record "Record Link";

       begin

           recEnquiries.DeleteAll();

           recEnquiriesLine.DeleteAll();

           rec_SalesHeader.Reset();

           recEnquiries.Reset();

           rec_SalesHeader.SetRange("Document Type", enumSalesDocType::Order);

           if rec_SalesHeader.FindSet() then begin

               repeat

                   recEnquiries.SetRange(No, rec_SalesHeader."No.");

                   if not recEnquiries.FindFirst() then begin

                       recEnquiries.Init();

                       recEnquiries.Id := CreateGuid();

                       recEnquiries.No := rec_SalesHeader."No.";

                       recEnquiries."Sell-to Customer Name" := rec_SalesHeader."Ship-to Name";

                       recEnquiries.Contact := rec_SalesHeader."Ship-to Contact";

                       recEnquiries.Address := rec_SalesHeader."Ship-to Address";

                       recEnquiries.County := rec_SalesHeader."Ship-to County";

                       recEnquiries.Postcode := rec_SalesHeader."Ship-to Post Code";

                       recEnquiries.Country := rec_SalesHeader."Ship-to Country/Region Code";

                       recEnquiries.Email := rec_SalesHeader."Sell-to E-Mail";

                       recEnquiries.Phone := rec_SalesHeader."Ship-to Contact";

                       recEnquiries."Sell-to City" := rec_SalesHeader."Ship-to City";

                       recEnquiries."Ship-to-Contact" := rec_SalesHeader."Ship-to Contact";

                       recEnquiries."Ship-to City" := rec_SalesHeader."Ship-to City";

                       recEnquiries."Ship-to County" := rec_SalesHeader."Ship-to County";

                       recEnquiries."Ship-to Post Code" := rec_SalesHeader."Ship-to Post Code";

                       recEnquiries."Ship-to Country" := rec_SalesHeader."Ship-to Country/Region Code";

                       recEnquiries."Ship-to Address" := rec_SalesHeader."Ship-to Address";

                       rec_SalesHeader.CalcFields("Amount Including VAT");

                       recEnquiries."Total Value" := rec_SalesHeader."Amount Including VAT";

                       recEnquiries.History := GetSalesHistory(rec_SalesHeader."No.");

                       recEnquiries.Reference := rec_SalesHeader."Your Reference";

                       recEnquiries.Description := rec_SalesHeader."External Document No.";

                       // recEnquiries."Internal Notes" := rec_SalesHeader.customDeliveryNotes;

                       recEnquiries.isArchive := false;

                       recEnquiries.DateCreated := DT2DATE(rec_SalesHeader.SystemCreatedAt);

                       recEnquiries."Sell-to Customer No." := rec_SalesHeader."Sell-to Customer No.";

                       recEnquiries."Location Code" := rec_SalesHeader."Location Code";

                       recEnquiries.Status := rec_SalesHeader.Status;

                       if rec_SalesHeader.HasLinks then

                           //if not recEnquiries.HasLinks then

                               recEnquiries.CopyLinks(rec_SalesHeader);

                       recEnquiries.Insert();

                       InsertSalesLine(recEnquiries.No);

                   end

                   else begin

                       if rec_SalesHeader.HasLinks then begin

                           recordlink.SetRange("Record ID", recEnquiries.RecordId);

                           if recordlink.FindSet() then begin

                               recEnquiries.DeleteLinks();

                           end;

                           recEnquiries.CopyLinks(rec_SalesHeader);

                       end;

                   end;

               until rec_SalesHeader.Next() = 0;

           end;

  • Nitin Verma Profile Picture
    21,812 Moderator on at

    I dont understand why you added your else condition., check it carfully.

    procedure InsertEnquiriesHeader()
    
       var
    
           recEnquiries: Record Enquiries;
    
           rec_SalesHeader: Record "Sales Header";
    
           rec_SalesHeaderArchive: Record "Sales Header Archive";
    
           enumSalesDocType: Enum "Sales Document Type";
    
           recEnquiriesLine: Record "Enquiries Line";
    
           versionNo: Integer;
    
           recordlink: Record "Record Link";
    
       begin
    
           recEnquiries.DeleteAll();
    
           recEnquiriesLine.DeleteAll();
    
           rec_SalesHeader.Reset();
    
           recEnquiries.Reset();
    
           rec_SalesHeader.SetRange("Document Type", enumSalesDocType::Order);
    
           if rec_SalesHeader.FindSet() then begin
    
               repeat
    
                   recEnquiries.SetRange(No, rec_SalesHeader."No.");
    
                   if not recEnquiries.FindFirst() then begin
    
                       recEnquiries.Init();
    
                       recEnquiries.Id := CreateGuid();
    
                       recEnquiries.No := rec_SalesHeader."No.";
    
                       recEnquiries."Sell-to Customer Name" := rec_SalesHeader."Ship-to Name";
    
                       recEnquiries.Contact := rec_SalesHeader."Ship-to Contact";
    
                       recEnquiries.Address := rec_SalesHeader."Ship-to Address";
    
                       recEnquiries.County := rec_SalesHeader."Ship-to County";
    
                       recEnquiries.Postcode := rec_SalesHeader."Ship-to Post Code";
    
                       recEnquiries.Country := rec_SalesHeader."Ship-to Country/Region Code";
    
                       recEnquiries.Email := rec_SalesHeader."Sell-to E-Mail";
    
                       recEnquiries.Phone := rec_SalesHeader."Ship-to Contact";
    
                       recEnquiries."Sell-to City" := rec_SalesHeader."Ship-to City";
    
                       recEnquiries."Ship-to-Contact" := rec_SalesHeader."Ship-to Contact";
    
                       recEnquiries."Ship-to City" := rec_SalesHeader."Ship-to City";
    
                       recEnquiries."Ship-to County" := rec_SalesHeader."Ship-to County";
    
                       recEnquiries."Ship-to Post Code" := rec_SalesHeader."Ship-to Post Code";
    
                       recEnquiries."Ship-to Country" := rec_SalesHeader."Ship-to Country/Region Code";
    
                       recEnquiries."Ship-to Address" := rec_SalesHeader."Ship-to Address";
    
                       rec_SalesHeader.CalcFields("Amount Including VAT");
    
                       recEnquiries."Total Value" := rec_SalesHeader."Amount Including VAT";
    
                       recEnquiries.History := GetSalesHistory(rec_SalesHeader."No.");
    
                       recEnquiries.Reference := rec_SalesHeader."Your Reference";
    
                       recEnquiries.Description := rec_SalesHeader."External Document No.";
    
                       // recEnquiries."Internal Notes" := rec_SalesHeader.customDeliveryNotes;
    
                       recEnquiries.isArchive := false;
    
                       recEnquiries.DateCreated := DT2DATE(rec_SalesHeader.SystemCreatedAt);
    
                       recEnquiries."Sell-to Customer No." := rec_SalesHeader."Sell-to Customer No.";
    
                       recEnquiries."Location Code" := rec_SalesHeader."Location Code";
    
                       recEnquiries.Status := rec_SalesHeader.Status;
    
                       if rec_SalesHeader.HasLinks then
    
                           //if not recEnquiries.HasLinks then
    
                               recEnquiries.CopyLinks(rec_SalesHeader);
    
                       recEnquiries.Insert();
    
                       InsertSalesLine(recEnquiries.No);
    
                   end else begin
                       if rec_SalesHeader.HasLinks then begin
                           recordlink.SetRange("Record ID", recEnquiries.RecordId);
                           if recordlink.FindSet() then begin
                               recEnquiries.DeleteLinks();
                           end;
                           recEnquiries.CopyLinks(rec_SalesHeader);
                           recEnquiries.insert();
    
                       end;
    
                   end;
    
               until rec_SalesHeader.Next() = 0;
    
           end;

  • Dividutt Profile Picture
    208 on at

    As this condition is for adding more than one notes without repeating the same notes , this was for from salesorder to enquire card, now I want to copy notes of enquiry card to sales order vise versa,

    What can be done for that in code? another if statement?

    Please help

    Thankyou

  • Dividutt Profile Picture
    208 on at

    With this function I am able to copy notes my sales order to enquire:

        if rec_SalesHeader.HasLinks then

                           recEnquiries.CopyLinks(rec_SalesHeader);

                      recEnquiries.Insert();

                     InsertSalesLine(recEnquiries.No);

                  end

                  else begin

                      if rec_SalesHeader.HasLinks then begin

                          recordlink.SetRange("Record ID", recEnquiries.RecordId);

                          if recordlink.FindSet() then begin

                              recEnquiries.DeleteLinks();

                          end;

                        recEnquiries.CopyLinks(rec_SalesHeader);

                      end;

                  end;

    But I want to copy notes from enquiry to sales header, how it's possible, I used the same function just change the table name,still not getting copied,so what can be done.

    Please any help in this very urgent,

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,002 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,255 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,217

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans