function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi,
Can anybody pls tell me how to retrieve list of Tasks for a particular Case using Apex coding.
I assume you are planning on doing this in a trigger?
You need to query the Task table for the ID of the case. Since tasks can relate to multiple objects, you need to check the WhatId.
The query should be something like this:
List<Case> caseList = [select id, name, subject from Task where WhatId IN :trigger.New];
Thanks a lot for your reply kyle :-)
I was not going to use it in a trigger.
This is what i tried, and it worked fine :
Id CaseID = Caseobj.Id; //Had already fetched the case object in the previous step
List<Task> TaskList = [Select Id, Subject, ActivityDate, Status, Priority, OwnerId, Description, IsDeleted, IsClosed, CreatedDate, LastModifiedDate, LastModifiedById From Task where WhatId = :CaseID];
I assume you are planning on doing this in a trigger?
You need to query the Task table for the ID of the case. Since tasks can relate to multiple objects, you need to check the WhatId.
The query should be something like this:
List<Case> caseList = [select id, name, subject from Task where WhatId IN :trigger.New];
All Answers
I assume you are planning on doing this in a trigger?
You need to query the Task table for the ID of the case. Since tasks can relate to multiple objects, you need to check the WhatId.
The query should be something like this:
List<Case> caseList = [select id, name, subject from Task where WhatId IN :trigger.New];
Thanks a lot for your reply kyle :-)
I was not going to use it in a trigger.
This is what i tried, and it worked fine :
Id CaseID = Caseobj.Id; //Had already fetched the case object in the previous step
List<Task> TaskList = [Select Id, Subject, ActivityDate, Status, Priority, OwnerId, Description, IsDeleted, IsClosed, CreatedDate, LastModifiedDate, LastModifiedById From Task where WhatId = :CaseID];
I'm quite new to Apex, could you tell me where you put the "Id CaseID = Caseobj.Id;" or how to fetch the case object ?
That'd help me greatly !
Regards,