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

Error while trying to reschedule Already scheduled apex job



  I have a visual force page which displays the list of scheduled Apex jobs. Now there is a schedule button. Onclick of the Schedule button , i need the class to be rescheduled to a value.


I m getting an INVALID Constructor error when i try to do this.


The following is my Controller code:


public class GetAllApexClasses {

    public  scheduleClicked () {
        return null;

    public String asyncapexjob { get; set; }

    public List<AsyncApexJob> apexclassList{get;set;}
    public GetAllApexClasses(){
    apexclassList = new List<AsyncApexJob>();
    apexclassList = [SELECT ApexClassID, Id, CompletedDate,Status,CreatedDate,TotalJobItems,CreatedBy.Name  from 

public  sheduleClicked () 

   sheduleClicked p = new sheduleClicked();
        String sch = '0 0 8 13 2 ?';
        system.schedule('One Time Pro', sch, p);

 The Following is my VF page code


<apex:page controller="GetAllApexClasses">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!apexclassList}" var="apexclass">
<apex:column headerValue="Class Name" >
<apex:outputField value="{!apexclass.ApexClassID}"/></apex:column>
<apex:column headerValue="Completed Date" >
<apex:outputField value="{!apexclass.CompletedDate}"/></apex:column>
<apex:column headerValue="Status" >
<apex:outputField value="{!apexclass.Status}"/>
<apex:column headerValue="Created By" >
<apex:OutputField value="{!apexclass.CreatedBy.Name}"/>
<apex:column headerValue="CreatedDate" >
<apex:outputField value="{!apexclass.CreatedDate }"/>
<apex:column headerValue="TotalJobItems">
<apex:outputField value="{!apexclass.TotalJobItems}"/>
 <apex:column headerValue="Schedule ">
 <apex:commandButton id="cb1" action="{!sheduleClicked}" value="schedule" /> 

 The following is the error which i m getting.


Error: GetAllApexClasses Compile Error: Invalid constructor name: scheduleClicked at line 4 column 13



Best Answer chosen by Admin (Salesforce Developers) 

Hi Navneeth,


You have to use public void sheduleClicked () instead of public sheduleClicked () in your controller because it is method not a constructor.


Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator