+ Start a Discussion
Ankit Singh 6Ankit Singh 6 

Fetching contact and their activities in a single api call

Hi All

We are trying to fetch contacts along with their activities.
Is there a way to fetch it in one api call (or using single soql query)? We know the way to fetch in two api calls (ie first fetch contact and then fetch activity based on whoid). I need  some way to join both objects.

Please help me out with this.

Regards
Ankit
Best Answer chosen by Ankit Singh 6
sslodhi87sslodhi87
Hi Ankit,

Please try using below mentioned query
SELECT Id, (SELECT Id FROM Tasks), (SELECT Id FROM Events)FROM Contact

Please let me know if this works

Thanks

All Answers

sslodhi87sslodhi87
Hi Ankit,

Please try using below mentioned query
SELECT Id, (SELECT Id FROM Tasks), (SELECT Id FROM Events)FROM Contact

Please let me know if this works

Thanks
This was selected as the best answer
Ankit Singh 6Ankit Singh 6
Thanks..It worked fine.