function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
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
Thanks. I 've done this yesterday. Then i checked with your coding. I got an error ContactList doesn't exist!
My code:
Map<Id,List<String>> accountemailmap = new Map<Id,List<string>>();
for(contact con : [Select id,accountId,email from contact where email!=null and accountId!=null]){
List<String> emaillst = accountemailmap.get(con.AccountId);
if(emaillst == null)
emaillst = new List<String>();
emaillst.add(con.email);
accountemailmap.put(con.accountId,emaillst);
system.debug('accountemailmap'+accountemailmap);
}
Regards,
Sfdccouple
sfdccouple.com