You need to sign in to do that
Don't have an account?
Argument must be an object that implements Database.Batchable
Im trying to run a batch apex for my code
/************************************************************************/
EscalateAnnualEnrollmentTaskProcess AE = new EscalateAnnualEnrollmentTaskProcess();
database.executebatch(AE);
/************************************************************************/
global class TaskProcess implements Schedulable {
global void execute(SchedulableContext ctx)
{
/* */
List<Request__c> requestIds = [SELECT Id FROM Request__c WHERE status__c != 'ACCEPTED'];
/* list of tasks associated near overdue activitydate - 5*/
List<Task>Overdue =new List<Task>([SELECT Id, ActivityDate, Subject FROM Task WHERE WhatId IN :requestIds AND IsClosed = false]);
/* iterate over the tasks */
for (Task t:tasksNearOverdue) {
/* lookup the object */
Request__c request = [SELECT Id, Project_Manager__c, Director__c FROM Request__c WHERE Id = :t.WhatId];
/* lookup the user and send the email*/
User manager = [SELECT Id, Name, Email FROM User WHERE Id = :request.Project_Manager__c];
sendemail(projectmanager, t);
/* lookup the user and send the email */
User director = [SELECT Id, Name, Email FROM User WHERE Id = :request.Director__c];
sendemail(director, t);
}
}
global void sendemail(User u, Task t)
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string[] toaddress = New String[] {u.Email};
email.setSubject('Task Almost Overdue');
email.setPlainTextBody(t.Subject + 'is due ' + t.ActivityDate + ' and needs some attention.');
email.setToAddresses(toaddress);
Messaging.sendEmail(New Messaging.SingleEmailMessage[] {email});
}
}
This is because you are implementing the schedulable rather than batchable interface Shedulable allows apex code to be scheduled, but you can't invoke executebatch on it.
All Answers
It is giving me the error " Argument must be an object that implements Database.Batchable"
This is because you are implementing the schedulable rather than batchable interface Shedulable allows apex code to be scheduled, but you can't invoke executebatch on it.
Thanks Bob. This code is for email alerts for the project manager and Directors for Overdue tasks. I wanted to see if the code is working.. How do I test for schedulable jobs
There's an example test class at:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm
Thanks Bob.. I wil figure it out..
Hi,
In your apex class add the (implements Database.Batchable<sObject>) line,
instead of implements Schedulable
For Ex,
global class TaskProcess implements Database.Batchable<sObject> {
//your code
for more info read theblogreaders.com