codeunit 60019 "TestCopyReference"
{
trigger OnRun()
begin
TestCopyReference();
end;
local procedure TestCopyReference()
var
Customer: Record Customer;
CustomerTemp: Record Customer temporary;
CustomerTemp2: Record Customer temporary;
begin
//Selecting Customer with specified name
Customer.SETRANGE(Name, 'Spotsmeyer''s Furnishings');
Customer.FINDFIRST;
//Copy Customer to Temp1 variable and get cursor
CustomerTemp.INIT;
CustomerTemp := Customer;
CustomerTemp.INSERT;
//Copy Customer from Temp1 to Temp2 with reference
CustomerTemp2.COPY(CustomerTemp, TRUE);
//Modifying Customer Name in Temp1
CustomerTemp.Name := 'Test Name';
CustomerTemp.MODIFY;
//Getting latest data from Temp2
CustomerTemp2.FIND;
//Customer Name in Temp2 will be: 'Test Name'
MESSAGE('%1', CustomerTemp2.Name);
end;
}