You need to sign in to do that
Don't have an account?
bujji
SOQL query for Task,Opportunity and Account
Hi Guys,
I need a query to bring all the tasks of Account and tasks of Opportunities which related to the Account.
I have written a query which is bringing all tasks of Opprotunities of related Account, see the below query
List<Task> taskList = [select Id,OwnerId,whoId,whatId,Subject,ActivityDate,Priority,Status From Task
where whatid IN (select Id From Opportunity where Account.Id ='0019000000DOsVO')
];
along with this i need the task of Account also. How to do it.
give me some suggestion. Urgent please.
Thanks,
Bujji
Get account ids into a list named AccountIdslst and query all opportunities for that account by
list<Ids>OpportunityIdslst = [Select Id from opportunity where accounid in :AccountIdsSet ];
Now combine all the ids, accountids+opportunityIds
aet<Id> AllIds = New aet<Id>()
AllIds.addAll(AccountIdslst);
AllIds.addAll(OpportunityIdslst);
Now query Tasks for both opportunity and accounts by
List<Task> allTasks = [select id, other fields from task where whatid in :AllIds]
Hope this helps