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
Alfredo Ornelas 4Alfredo Ornelas 4 

Delete Marketo tasks apex class

Hi,
Can you share a code and controller on how to delete tasks created by Marketo user? I want to clean up tasks on a weekly basis due to data storage limitations. Thanks
Best Answer chosen by Alfredo Ornelas 4
mritzimritzi
I would suggest you to use scheduled Apex class.

Sample Schedulable Apex class:
 
global class NameOfClass implements Schedulable {
    
    global void execute(SchedulableContext ctx) {
		try{
			List<ObjectName__c> delList = [Select id From ObjectName__c Where CreatedBy.Name='Full name of User'];
//other alternatives to filter records -> Createdby.Alias, FirstName etc
			delete delList;
		}catch(Exception e){
			System.debug(e);
		}
	}
}

i) Write an apex class in line with above mentioned example.
ii)Click on "Schedule Apex" button on Apex Class page.
iii) Select the apex class
iv) Set time,date,frequency for repetitive class exceution

And you are done.


Select it as Best Answer, if it solves your problem.

All Answers

Alfredo Ornelas 4Alfredo Ornelas 4
Maybe a Trigger?
mritzimritzi
I would suggest you to use scheduled Apex class.

Sample Schedulable Apex class:
 
global class NameOfClass implements Schedulable {
    
    global void execute(SchedulableContext ctx) {
		try{
			List<ObjectName__c> delList = [Select id From ObjectName__c Where CreatedBy.Name='Full name of User'];
//other alternatives to filter records -> Createdby.Alias, FirstName etc
			delete delList;
		}catch(Exception e){
			System.debug(e);
		}
	}
}

i) Write an apex class in line with above mentioned example.
ii)Click on "Schedule Apex" button on Apex Class page.
iii) Select the apex class
iv) Set time,date,frequency for repetitive class exceution

And you are done.


Select it as Best Answer, if it solves your problem.
This was selected as the best answer
Alfredo Ornelas 4Alfredo Ornelas 4
Thanks!