Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

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

Posted on by 200

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.

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Copy my notes from sales order to Enquiry and enquiry to sales

    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

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Copy my notes from sales order to Enquiry and enquiry to sales

    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

  • Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Copy my notes from sales order to Enquiry and enquiry to sales

    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
    Dividutt 200 on at
    RE: Copy my notes from sales order to Enquiry and enquiry to sales

    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;

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Copy my notes from sales order to Enquiry and enquiry to sales

    Show your complete code.

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,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans