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
RoyalRoyal 

can i schedule normal apex from schedule class ?

can i schedule normal apex from schedule class ?

Thanks
 
MagulanDuraipandianMagulanDuraipandian
No. You should hav a class which implements Schedulable.

http://www.infallibletechie.com/2012/05/apex-scheduler.html
Amit Chaudhary 8Amit Chaudhary 8
No you can not schedule the Normal Apex class. If you want to schedule any class you need to implements Schedulable interface.
1) https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_scheduling_1.htm
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_system_schedulable.htm

Schedulable Methods
The following are methods for Schedulable.

execute(context)
global class MySchedulableClass implements Schedulable {
   global void execute(SchedulableContext ctx) {
      CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
                FROM CronTrigger WHERE Id = :ctx.getTriggerId()];

      System.debug(ct.CronExpression);
      System.debug(ct.TimesTriggered);

      Merchandise__c m = new Merchandise__c(
                    Name='Scheduled Job Item',
                    Description__c='Created by the scheduler',
                    Price__c=1,
                    Total_Inventory__c=1000);
      insert m;
   }   
}

How to schedule
http://www.infallibletechie.com/2012/05/apex-scheduler.html

Please let us know if this will help you
RoyalRoyal

Sorry may be you are confused, i know about schedule class, my question is in schedule class from the execute method can i call a normal batch class method ?

i know is it possible to call batch class..like that can call noemal apex class method ?

i think now it is clear ...!

Thanks
Deepthi BDeepthi B
Hello Boyapati,

Ofcourse you can call a batch process from a schedule class. Thus making the batch process to be scheduled.
Please check the sample code that can be inserted in the execute method of schedule class.
BatchApexclass bc = new BatchApexclass ();
Database.executeBatch(bc);
Hope this may help you!

Regards,
Deepthi