You need to sign in to do that
Don't have an account?
someone
Query for Task with Account and Contact information at the same time
I have a method to query for a specific Task object (or list of Tasks) based on the ID(s) of the object as follows:
How can I also query for the Account object (with Cases, Opportunities, Contracts) and the Contact object all in the same query?
Thanks
webService static String getTasksByIds(String idsAsJson) { Set<Id> taskIds = (Set<Id>) JSON.deserialize(idsAsJson, Set<Id>.class); List<Task> tasks = [SELECT Id, IsClosed, Status, Subject, Description, WhoId, Account.Name FROM Task WHERE Id IN : taskIds]; Map<Id, Task> taskMap = new Map<Id, Task>(); for (Task t : tasks) { taskMap.put(t.Id, t); } return JSON.serialize(taskMap); }
How can I also query for the Account object (with Cases, Opportunities, Contracts) and the Contact object all in the same query?
Thanks
But adding something like Opportunity.Name will not work.