You need to sign in to do that
Don't have an account?
Pooja Singh 21
Batch job to delete all tasks related to Case with record type X.
Hi,
I need help writing a batch job which can help deleting all tasks related to cases with record type 'X'. Can anyone share a dummy code for same?
Thanks,
Pooja
I need help writing a batch job which can help deleting all tasks related to cases with record type 'X'. Can anyone share a dummy code for same?
Thanks,
Pooja
Please use below code for reference
Please implement this and let me know if it helps you...
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
Thanks for your reply.
I am stuck only in the execute method. I have got all the cases with record type X now in a list. Can you please give me a proper code to extract all the tasks related to those cases and delete them. This will help a lot.
Thanks,
Pooja
please check and let me kbow if it helps ..
Please try above code snippt and let me knwo if it works you....also let me know if you need any clarfiction for above code..
thanks
Task[] task = [select Id, RecordType... from Task where...]
then:
List<Task> deleteList = new List<Task>()
for (Task t in task)
{
if(t,recordType=='X')
deleteList.add(t);
}
Last, delete those records
if(deleteList.size>0)
{ delete deleteList;
deleteList.clear()
}
hope this help~
I am working on the code. There may be a possibility to add couple of more requirements in it. Once it works, I will let you know.
I do not think that there is any Record Type field for Task object so this approach is not suitable.