Om trying to create a check which when the user closes the customer card it should check to see if any of the Address fields Have changed. If it has it should then change the sales orders relating to that customer with the correct Information.
Currently I have came up with this quickly, however how can i Make it more efficient.
Customer Card (OnOpenPage)
Rec := recCustomer1;
grecCustomer2 := recCustomer1;
Customer Card (OnClosePage)
cuLewisDev.CustomerAddressamendment(recCustomer1,grecCustomer2);
In the Codeunit
CustomerAddressamendment(grecCustomer2 : TEMPORARY Record Customer;recCustomer1 : Record Customer)
IF recCustomer1.Address <> grecCustomer2.Address THEN
UpdateSalesorder(recCustomer1, grecCustomer2);
IF recCustomer1."Address 2" <> grecCustomer2."Address 2" THEN
UpdateSalesorder(recCustomer1, grecCustomer2);
IF recCustomer1.City <> grecCustomer2.City THEN
UpdateSalesorder(recCustomer1, grecCustomer2);
IF recCustomer1.Contact <> grecCustomer2.Contact THEN
UpdateSalesorder(recCustomer1, grecCustomer2);
IF recCustomer1.Name <> grecCustomer2.Name THEN
UpdateSalesorder(recCustomer1, grecCustomer2);
IF recCustomer1."Post Code" <> grecCustomer2."Post Code" THEN
UpdateSalesorder(recCustomer1, grecCustomer2);
IF recCustomer1.City <> grecCustomer2.City THEN
UpdateSalesorder(recCustomer1, grecCustomer2);
UpdateSalesorder(recCustomer1 : Record Customer;grecCustomer2 : TEMPORARY Record Customer)
recSalesOrder.RESET;
recSalesOrder.SETRANGE("Sell-to Customer No.", recCustomer1."No.");
IF recSalesOrder.FINDSET(TRUE,FALSE) THEN
IF CONFIRM('Do you want to Update Sales order',FALSE) = FALSE THEN
EXIT;
recSalesOrder."Bill-to Name" := recCustomer1.Name;
recSalesOrder."Bill-to Address 2" := recCustomer1."Address 2";
recSalesOrder."Bill-to Address" := recCustomer1.Address;
recSalesOrder."Bill-to City" := recCustomer1.City;
recSalesOrder."Bill-to Post Code" := recCustomer1."Post Code";
recSalesOrder."Bill-to Contact" := recCustomer1.Contact;
recSalesOrder.MODIFY;
*This post is locked for comments