+ Start a Discussion
hkp716hkp716 

Scheduled Apex Job

Hi everyone,

 

I have a couple of question. How do i get my scheluded apex job to show up in monitoring?  How can i add picklist values from status in my String checkLead?  if i add status = 'open', 'closed' at the end the string breaks because im adding  '.  

 

 

-hkp716

 

apex class:

 

global class leadfollowup30day implements Schedulable{

global void execute(SchedulableContext sc)
{
leadfollowup30day t = new leadfollowup30day();
        String sch = '0 0 11 * * ?';
        system.schedule('30 day lead followup', sch, t);
}
public static Date todayMinusThirty = system.Today().addDays(-30);


public static String checkLead = 'select Id, status, LastModifiedDate from Lead WHERE (LastActivityDate = :todayMinusThirty OR LastActivityDate = NULL) AND LastModifiedDate = :todayMinusThirty';


public static void updateLeads ()
{

//system.debug('\n\n30 checkLead ' + checkLead);
//collect a list of records

List <Lead> setfollow = Database.query(checkLead);

for (Lead ld :setfollow)
{
    Task t = new Task();
    t.Subject = 'Needs Follow up - No Activity in 30 days';
    t.OwnerID = ld.OwnerID;
}


}
}

Jia HuJia Hu
try this,

............. And status IN (\'open\', \'closed\')';
Jia HuJia Hu
You can execute the following lines in the 'Execute Anonymous' mode,

leadfollowup30day t = new leadfollowup30day();
String sch = '0 0 11 * * ?';
system.schedule('30 day lead followup', sch, t);

then it will be submitted to the Monitoring -> Scheduled Jobs
hkp716hkp716

Hi Jia Hu,

 

Thanks for the response, i figured i would execute anonymously.  I'll test the new string and get back to you.

 

-hkp716

hkp716hkp716

Hey Jia Hu,

 

The job was scheduled and the class ran but it did not assign a task.  I think theres something wrong with my list query.

 

Thanks for the help,

hkp716