+ Start a Discussion
Abby StockerAbby Stocker 

Code ideas needed!

Hello! I have created an apex class (below) that will get the current case Id. Now I need another class on Task that will get all tasks related to that current case record and store them in something (a list?). That way, I can use both of those apex classes in a trigger. Any idea on how to write the class on Task (get a list of all tasks related to the current case record Id)? I know i need to use Id and Whatid but I am just not sure how to format it out. Thank you!!! (getcurrentrecord code below).
public class currentCaseRecord {
        Case currentRecord;
    public currentCaseRecord (ApexPages.StandardController controller){
        currentRecord = [Select Id FROM Case Where Id =:ApexPages.CurrentPage().getparameters().get('id')];
        }
    public case getcurrentRecord(){
        return currentRecord;
    }
}
Best Answer chosen by Abby Stocker
Danish HodaDanish Hoda
For querying tasks:
List<Task> tasks = [SELECT id, subject from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id')];

All Answers

Danish HodaDanish Hoda
For querying tasks:
List<Task> tasks = [SELECT id, subject from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id')];
This was selected as the best answer
Abby StockerAbby Stocker
Perfect. Thank you! I kept getting errors on my query and now I see why. Thank you!!!