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
wt35wt35 

System Log: how to run a class

Hello

 

Sorry if this has been posted already but I am looking for the syntax to run a class from an anonymous block in the system log.

 

This is the class:

 

global class checkSupportDailyTarget implements Schedulable{
    
   global void execute(SchedulableContext sc) {

   //do some work  
}

 

I 've tried this:

 

checkSupportDailyTarget  a = new checkSupportDailyTarget ();
a.execute();

 

But I get the error 

Compile Error: line 2, column 1: Method does not exist or incorrect signature: [checkSupportDailyTarget].execute()

 

 

Thank you

Marc

nandurinanduri

to run a schedule class

 

checkSupportDailyTarget a = new checkSupportDailyTarget ();

String sch = '20 30 8 10 2 ?'

system.schedule('Schedule1 Job', sch, m);

 

 

U may schedule it any time, for more on scheduling please check

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

wt35wt35

Thank you but actually I am looking for a way to run it instantaneously from the System Log  to see how my class works before scheduling it.

bob_buzzardbob_buzzard

You can't really hit the execute directly, as it requires a SchedulableContext and I'm not aware of any way to generate one of these yourself.

 

The way around this I would say is to have your execute method simply call another method that does the work.  Then you can call that directly once you've instantiated the class, as long as you don't need to get at any part of the SchedulableContext object.