function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DEV_CGDEV_CG 

how to clone the records with out using clone() and deepClone()

Hi everyone,
I want to clone the Accounts and respective ccontacts through trigger without using existing methods in salesforce.
could anyone please suggest?
 
Raj VakatiRaj Vakati
You need to create using new Sobject and insert it 

like below 
 
trigger OppCustomClone on Opportunity(after update){
	List<Opportunity> dtType = new List<Opportunity>();
	for(Opportunity o :Trigger.new){
		
		Opportunity oTemp = new Opportunity() ;
		oTemp.Name =o.Name ; 
		oTemp.Amount =o.Amount ; 
		oTemp.CloseDate =o.CloseDate ; 
		oTemp.StageName =o.StageName ; 
		dtType.add(oTemp) ;
		
	}
	
	insert oTemp;
	
}


If you are calling the using after insert trigger  .. make sure you are the trigger is not firing recursively