Soubhik
2/17/2020 - 7:19 PM

23

Create a field on Contact called Profile, text, 255

Assignment: When an Account is updated and the Website is filled in, update all the Profile field on all Contacts to:

Profile = Website + ‘/’ + First Letter of First Name + Last Name

trigger UpdateContactByAccount on Account (After Update) {
    List<Contact> contacts=new List<Contact>();
    For(Account acc:trigger.new){
        ID accid=acc.Id;
        //cons.Profile__c='Website + ‘/’ + First Letter of First Name + Last Name';
        List<Contact> listOfContact=[select id From Contact Where Account.Id=:acc.Id And Account.Website !=null];
        For(Contact contactItem:listOfContact){
           //contactItem.Profile__c=contactItem.Website + '/' + contactItem.FirstName + contactItem.LastName;
           
            contacts.add(contactItem);
        }
    
        
    }
    update contacts;
     
}