copy customer records from one company to another using dynamics axapta

You can copy customer records from one company to another using dynamics axapta code. This is example of job. You can test this job by directly copy paste to new job in axapta.

 static void RecordCopy(Args _args)  
 {  
 CustTable custTable1;  
 CustTable custTable2;  
 ;  
 custTable1 = CustTable::find('11111');  
 changecompany('TET')  
 {  
 ttsbegin;  
 buf2buf(custTable1, custTable2);  
 custTable2.AccountNum = '1234';  
 custTable2.PartyId = '';  
 custTable2.PartyId = DirParty::createPartyFromCommon(  
 custTable2).PartyId;  
 if (!custTable2.validateWrite())  
 {  
 throw Exception::Error;  
 }  
 custTable2.insert();  
 ttscommit;  
 }  
 }