+ Start a Discussion

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