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
Alan MonkAlan Monk 

Run a scheduled job in visual force page

Hi Guys, I am new to Visual force development and need some help.

I have created a custom link on my home page to run a scheduled job immediately. I need to create a VF page to do this but need some help in creating the page text.

What I need to run is the following:

TelesalesDataProcessor runJob = new TelesalesDataProcessor();
runJob.execute(null);

Any help would be appreciated.

Thanks

Alan

 
Best Answer chosen by Alan Monk
Om PrakashOm Prakash
Hello Alan,
Sample code for your requirement is bellow:
public class TelesalesDataUtility{

   public void scheduleJob(){
     TelesalesDataProcessor runJob = new TelesalesDataProcessor();
     runJob.execute(null);
   }
}
 
<apex:page controller="TelesalesDataUtility">
  <apex:form>
      <apex:commandButton value ="Execute Job" action="{!scheduleJob}"/>
  </apex:form>
</apex:page>

 

All Answers

Om PrakashOm Prakash
Hello Alan,
Sample code for your requirement is bellow:
public class TelesalesDataUtility{

   public void scheduleJob(){
     TelesalesDataProcessor runJob = new TelesalesDataProcessor();
     runJob.execute(null);
   }
}
 
<apex:page controller="TelesalesDataUtility">
  <apex:form>
      <apex:commandButton value ="Execute Job" action="{!scheduleJob}"/>
  </apex:form>
</apex:page>

 
This was selected as the best answer
Alan MonkAlan Monk
Thank you for your help Om, much appreciated.
Om PrakashOm Prakash
Thanks Alan.