Skip to main content
2 respostas
  1. 5 de nov. de 2019, 09:53
    Hi,

    I've gone through your requirement and you can find the apex code for mapping account and contact below:

    List<Account> allaccounts=new List<Account>([select id,Name from Account limit 1000]);

    List<Contact> allcontacts=new List<Contact>([select id,Name,Email,AccountId from Contact where AccountID IN:allaccounts]);

         for(Contact contacts:contactsList)

            {

                 if(ConAccMap.containsKey(contacts.AccountId))

                   {   

                    ConAccMap.get(contacts.AccountId).add(contacts);

                       

                   }

                else 

                   {   

                    

                    ConAccMap.put(contacts.AccountId,new list<contact>{contacts}); 

                    ConAccMap.get(contacts.AccountId).add(contacts);

                   }

            }

    I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

    Thanks and Regards,

    Deepali Kulshrestha

    www.kdeepali.com
0/9000