+ Start a Discussion
iswarya sekar 7iswarya sekar 7 

I need to create a custom field in parent case,where the child case emails should be auto populated in that custom field.For example,a parent case has three child cases.Then the three email should be there in that custom field with Semicolon.

Best Answer chosen by iswarya sekar 7
v varaprasadv varaprasad
Hi Iswarya,

Please find sample code below : 
trigger ContactNamesOnAccount on Contact (after update, after insert) 
   Set<id> accIdList = new Set<id>();
   for(Contact con : Trigger.new)

   List<Account> accUpdateList = new List<Account>();
   for(Account acc : [Select id, name, Contact_Names__c, 
                             (Select Id, name, LastName From Contacts) 
                        From Account Where Id In : accIdList])
    List<String> lstSrting = new List<String>();
    for(Contact con : acc.contacts)
    acc.Contact_Names__c = String.join(lstSrting, ',');
   update accUpdateList;

Hope it helps you.
If the above information is informative please mark it as the best answer.

if you any other assistance please let me know.