function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rajubalajirajubalaji 

how to write a class for delete, we need to get status and see if delete transcation was sucess or not?

Hi Everyone,

How to write a program in apex class for delete a task object and i need to get status and see if delete task was success or not.

if anyone know please help me.thanks inadvance.

thanks,
balaji
VinayVinay (Salesforce Developers) 
Hi Balaji,

Review below link which has example of deletion of tasks.

https://salesforce.stackexchange.com/questions/1133/custom-button-to-delete-some-tasks
https://developer.salesforce.com/forums/?id=9060G000000BgaNQAS

Thanks,
Vinay Kumar
rajubalajirajubalaji
Hi Vinay,

Thanks for very quick help.please find the below code.can you please  help me where i need to write the status of the transcation.
public static void DataDelete(id taskId) {
        Savepoint sp = Database.setSavepoint();
        try{
            List<Task> task = [SELECT id from task where Id =:taskId];
            if(task.isEmpty()){
                return;
            }
            else{
                delete Task;
            }

thanks inadvance.