0

i am scheduling hourly one class by using

PortalUserDisableBatch pudbatch = new PortalUserDisableBatch();

String CRON_EXP = '0 0 * * * ?';

System.schedule('Hourly', CRON_EXP, pudbatch ); 

i need to move it into UAT and Production. Do i need to do same in UAT and Production or is there any way to deploy like creating change sets

0

System.Schedule is a static method for system operations which belongs to System Class. You can't include a system method command in a change set. For more information on System Methods

You can implement a schedulable class to schedule your batch class. This class can be included in a change set.

global class SchedularForBatchApex implements Schedulable {

        global void execute(SchedulableContext sc) {
            myBatchClass d = new myBatchClass();
              database.executebatch(d, 10);
        }

         Public static void SchedulerMethod(){
             SchedularForBatchApex s = new SchedularForBatchApex();
             String cron_exp = '0 59 * * * *';
             System.schedule('myBatchClass', cron_exp, s);
         }

 }
  • So, we need to run that schedule class in anonymous window for Production right? – Neymar Da Silva Feb 8 '16 at 11:12
  • @NeymarDaSilva yes, click Debug. Open Execute Anonymous Window to open the Enter Apex Code window. Enter the code you want to run in the Enter Apex Code window or click to open the code editor in a new browser window. To automatically open the resulting debug log when execution is complete, select Open Log. – Jarvis Feb 8 '16 at 11:20
  • @NeymarDaSilva Did it help ? If yes accept the answer so that it's helpful for others who would have a similar question – Jarvis Feb 8 '16 at 13:11
  • 1
    @NeymarDaSilva one extra bit -- when you use DC in PROD, be sure to log in as the user you want to be the running user for the schedulable class. This improves traceability a lot as any updates done by the schedulable class can be traced back to the desired intent rather than some random sysad – cropredy Feb 8 '16 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.