You need to sign in to do that
Don't have an account?
Vijay Kumar Rebbala 1
Error: Compile Error: expecting right curly bracket, found 'try' at line 3 column 4
global class DeleteoldCases{
List<Case> QueryCases = [SELECT Id FROM Case WHERE Case.CreatedDate < LAST_N_MONTHS:18 ORDER BY CreatedDate ASC LIMIT 9000];
try{
delete QueryCases;
}catch(DmlException e) {
System.debug('An unexpected error has occurred: ' + e.getMessage());
}
}
List<Case> QueryCases = [SELECT Id FROM Case WHERE Case.CreatedDate < LAST_N_MONTHS:18 ORDER BY CreatedDate ASC LIMIT 9000];
try{
delete QueryCases;
}catch(DmlException e) {
System.debug('An unexpected error has occurred: ' + e.getMessage());
}
}
Best Answer chosen by Vijay Kumar Rebbala 1
Shashikant Sharma
Here you are trying to write try catch block and DML statement directly in the class. You should create a method in class to do so like below code