Skip to main content
8 Antworten
  1. 17. Juni 2021, 20:35

    I was whacking my head on this!! Why you thought to give the class name "Contact"? Try the below code and please rename your class name.

    public class contactclass {

    public static void m(){

    list<account> clist=[select id,name, (select Name from contacts) from account];

    for(Account a: clist){

    for(Contact c : a.Contacts){

    System.debug('Account Name:: '+a.Name + ' ' + 'Contacts: ' + c.Name);

    }

    }

    }

    }