Skip to main content
gowtham k (self) a posé une question dans #Salesforce Developer
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

Thanks

 
1 réponse
  1. 11 avr. 2016, 07:33
    HI 

    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(objlead.email != trigger.oldmap.get(objlead.Id).email)

    {

    Lead objLead = new Lead();

    objLead.status = '';//or qassign any value which you wnat to set and then insert

    lsLeadToInsert.add(objLead);

    }

    else

    {

    //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.

    Thanks,

    Sandeep

0/9000