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.
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
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
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;
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;
Show your complete code.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,113 Super User 2024 Season 2
Martin Dráb 229,918 Most Valuable Professional
nmaenpaa 101,156