Simple update operation using Trigger - Before

Simple update operation using Trigger - Before



Trigger theTriggerName on Contact(before insert, before update){
    List<Contact> contactsToUpdate = new List<Contact>();
    for(contact cont: Trigger.New){
        if(cont.phone == '' ||  cont.phone == null){
            cont.phone = '1234567890';
        }
        if(cont.email == '' ||  cont.email == null){
            cont.email = 'abcd.efgh@ijkl.com';
        }
        contactsToUpdate.add(cont);
    }    
}

Comments