Salesforce | Fetch all the tasks related to an sfobject

Author - Webner
3.03.2017
|
0 Comments
|

Description: I have a situation where I want to fetch all the tasks related to the account object.

Solution: You get all the task records which belong to any of SF object using single SQL query.

For Single object:
For Example, I want to query task related to accounts:

Qry=[SELECT Id,subject,What.Type,whatId FROM Event WHERE What.Type IN ('Account')]

For Multiple objects :
If you want to query tasks of more than one sf object you can do in this way:

Qry=[SELECT Id,subject,What.Type,whatId FROM Event WHERE What.Type IN ('Account',’Opportunity’)]
Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published.