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
THUNDER CLOUDTHUNDER CLOUD 

How to create lead backup for all lead records ?

I need to store all the lead records in a custom object (LeadBackups) such that when a lead record is updated then the associated leadbackup record will also get updated and when leadbackup  record is updated then associated lead record will be updated.
 
sandeep@Salesforcesandeep@Salesforce
Yoiu just need to write a trigger on Lead (insert /Update) and LeadBackup ( on Update event) object as below:

Here I am just giving you an idea how you can write a trigger
trigger SyncBackupLead on Lead(after Insert, before update)
{
	if(Trigger.isInsert)
	{
		List<backupLead__c> ListofbackupLead = new List<backupLead__c>();
		for(Lead originalLead : Trigger.New)
		{
			backupLead__c backupLead = new backupLead__c();		 
			backupLead = originalLead.clone(false, false , false , false);
			backupLead.OriginalLead__c = originalLead.id;
			ListofbackupLead.add(backupLead);
		}
		if(ListofbackupLead.size()>0)
			insert ListofbackupLead ;
	}
	else if(Trigger.isUpdate)
	{
		Map<id, backupLead__c> mapofBkpLeads = new Map<id, backupLead__c>();
		for( backupLead__c bkpL : [select id from backupLead__c where OriginalLead__c in : Trigger.new])
		{
			mapofBkpLeads.put(bkpL.OriginalLead__c, bkpL);
		}
		List<backupLead__c> bkpLeadsToupdate = new List<backupLead__c>();
		for(Lead originalLead : Trigger.New)
		{
			backupLead__c backupLead = new backupLead__c();		 
			backupLead = mapofBkpLeads.get(originalLead.id); 
			backupLead = originalLead.clone(false, false , false , false);
			backupLead.OriginalLead__c = originalLead.id;
			bkpLeadsToupdate .add(backupLead);
		}
		if(ListofbackupLead.size()>0)
			update bkpLeadsToupdate ;
	}		
}
I hope you got idead and you may write next trigger. 

mark this answer as best asnwer if it helps so that it may help other also. 

Thanks
Sandeep Singhal
http://www.codespokes.com/