You need to sign in to do that
Don't have an account?
Anoop Kumar 31
write a soql query to fetch 500 account records with all their related contacts and prepare a collection of accountid and its related contacts
Please answer anyone ??
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Try This :
More Info :
https://www.youtube.com/watch?v=Us9x9GyuRj8&t=5s
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For SFDC Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
All Answers
Or
But where is related contacts in this Query
Try This :
More Info :
https://www.youtube.com/watch?v=Us9x9GyuRj8&t=5s
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For SFDC Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Have a look at the code below:
public class relatedcontact {
public static void relatedlist()
{
List<Account> acList=[SELECT Name,(SELECT lastname from Contacts )from Account limit 500];
//System.debug('account list'+acList);
List<Contact> conList=new List<Contact> ();
Map<Id,List<Contact>> mymap=new Map<Id,List<Contact>>();
for(Account ac:acList)
{
if(ac.contacts.size()>0)
{
conList.addall(ac.Contacts);
//this list will contain all the contacts related to some particular accounts.
//we are not aware of which contact is related to which account,it only gives list of related contacts
mymap.put(ac.id,ac.Contacts);
//Whereas using Map collection here we have account's id and list of Contacts related to that account.
}
}
System.debug('Related list of Contacts'+conList);
System.debug('Map Collection of Account id and list of Contact'+mymap);
}
}
Hope this explanation will resolve your query.Mark it as best answer if you find it helpful.
Thanks.
Ajay Dubedi