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
Sana123Sana123 

Populate contact values from account field

#like i want to add more than one contact from the custom field of account then how can i add it
 for(account acc : trigger.new){
            setAccountIds.add(acc.Id);  
            }
        if(setAccountIds.size() > 0){
            for(account acc : [SELECT Id , Name ,Contacts__c From Account Where Id In : setAccountIds]){

                String addressFull  = acc.Contacts__c;
                String[] address     = addressFull.split(',');
                String f         =     address[0]; 
                String L          =    address[1];
                String m         =     address[2]; 
                String E          =    address[3];
                String f1 = f.substringAfter('='); 
                String f2 = L.substringAfter('=');
                String f3 = m.substringAfter('=');
                String f4 = E.substringAfter('=');
                
                     contact con = new contact();
                    con.firstname = f1;
                    con.LastName = f2;
                        
                con.MobilePhone = f3;
              con.Email = f4;
             con.AccountId = acc.Id;
               
             acc.Contacts__c ='FirstName'+  ' = ' + con.firstname + ' ,' + 'LastName' + ' = ' +  con.LastName +' ,' + 'MobilePhone' + ' = ' +  con.MobilePhone
                   +' ,'  + 'Email' + ' = ' +  con.Email;
              
            lstAccount.add(acc);  
            lstContact.add(con);
          
AbhinavAbhinav (Salesforce Developers) 
Hi Sana,

Please rephrase your question as it seems unclear.