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
Wasim AkramWasim Akram 

I want to fetch all the contacts with his parent account name using map only

RAM AnisettiRAM Anisetti
Hi akram,
try this one......
 
Map<String,List<Contact>>mapval=new Map<String,List<Contact>>();

List<Account>acc=[select name,(select id from contacts) from Account limit 2];
system.debug('-----'+acc);

for(Account a:acc){
    mapval.put(a.name,a.contacts); 
}
system.debug('-----'+mapval);


 
Wasim AkramWasim Akram

No I Want This On My Page Like..

Account Name 1
             Contact 1
             Contact 2

Account Name 2
            Contact 1
            Contact 2
            Contact 3

Wasim AkramWasim Akram
Contacts Field Not ID And Accounts Name Not ID