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
satheesh k 18satheesh k 18 

Lead email

Hi All,

I want to check lead email field value when will we insert new record , if old email id and new email id is same update same record. 
otherwise create new record in lead object.

Please help me how will i do
sandeep sankhlasandeep sankhla
PLease find the below code for same, where you can change for same condition and proceed accordingly.
UTrigger on Lead (before insert, before update)
			list<Task> lsLeadToInsert = new list<Task>();
				if(trigger.isInsert() && Trigger.isAfter())
						for(lead objlead : trigger.newmap)
						      if( != trigger.oldmap.get(objlead.Id).email)
								 Lead objLead = new Lead();
								 objLead.status = '';//or qassign any value which you wnat to set and then insert
							       //then do whatever you want to update on same insteance
						insert lsLeadToInsert

Please refer above code and let me know if that helps or you face any issue.