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
Dave The RaveDave The Rave 

Reschedule Apex Job using Dev Console

All, I had to delete a scheduled apex job, as this was running under my name.

Now I need to reschudule the apex job to run every hour.

Apex Class is below, can I reschedule this in the Dev Console <Open Execute Anomymouse Window"? and how can I do that?
 
/**
 * Schedulable class to retrieve external User Stories on a scheduled basis.
 *
 * @author Ümit Can Uçkan
 * @version 1.0
 * @since CCM Integrations 1.0
 */
global class ScheduleUserStoryFetch implements Schedulable
{
    copado__Project__c cpRecord;
    public ScheduleUserStoryFetch(Id pId){
        cpRecord = [SELECT Id,Name, Copado_Integration_Setting__r.External_System__c, Copado_Integration_Setting__r.Named_Credential__c,JQL_Extended_Filter__c,Enable_Logs__c,
                           Project_External_Id__c, Workspace_Id__c FROM copado__Project__c WHERE Id=:pId];
    }

    global void execute(SchedulableContext sc)
    {
        Database.executeBatch(new ExecuteUserStoryUpsert(this.cpRecord),200);
    }
}

 
Best Answer chosen by Dave The Rave
Suraj Tripathi 47Suraj Tripathi 47
Hi Dave,

Please try the below-updated code :

System.schedule('Hourly', '0 0 * * * ?', new ScheduleUserStoryFetch(pId ) ); //pId refers to id of any record od Copado_project__c object

I hope you find the above solution helpful. If it does, please mark it as Best Answer to help others too.
Thanks and Regards,
Suraj
 

All Answers

mukesh guptamukesh gupta
Hi Dave,

Please use below code in your developer console

This will scheduled the job to run in every hour starting from 12 AM
 
// Cron EXP for hourly schedule 
String CRON_EXP = '0 0 * * * ?'; 
ScheduleUserStoryFetch sch = new ScheduleUserStoryFetch(); 
system.schedule('Hourly Example Batch Schedule job', CRON_EXP, sch);

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 
Dave The RaveDave The Rave
Hi Mukesh,

This did not work, I got the following error in the dev console:
 
Line: 3, Column: 30
Constructor not defined: [ScheduleUserStoryFetch].<Constructor>()

 
Dave The RaveDave The Rave
Hi Suraj, thanks for the code. However, I tried both your solutions and still have the same error:
 
Constructor not defined: [ScheduleUserStoryFetch].<Constructor>()

 
Suraj Tripathi 47Suraj Tripathi 47
Hi Dave,

Please try the below-updated code :

System.schedule('Hourly', '0 0 * * * ?', new ScheduleUserStoryFetch(pId ) ); //pId refers to id of any record od Copado_project__c object

I hope you find the above solution helpful. If it does, please mark it as Best Answer to help others too.
Thanks and Regards,
Suraj
 
This was selected as the best answer
Dave The RaveDave The Rave
Sorry, Suraj, still an error

"Line: 1, Column: 69
Variable does not exist: pId"
Suraj Tripathi 47Suraj Tripathi 47

Hey Dave, 
As I have already written in the comment pID refers to record Id, which means you have to pass any record ID in it.
You can create a new record or use an existing record according to your code requirements.

Let me know if you need any assistance.

Hope it's working now. please mark it as Best Answer to help others too.
Thanks and Regards,
Suraj

 

Dave The RaveDave The Rave
Thanks Suraj for your help. Your solution works great!