Skip to main content
Post Closed as "Duplicate" by Matt Lacey
added 40 characters in body
Source Link
battery.cord
  • 8.9k
  • 8
  • 32
  • 59

I have a situation where I need to pass a string to schedulable controller from batch or any apex controller. I see that we can do it using public constructor in schedulable implementation. Please let me know how can I pass a String parameter to schedulable controller. I tried below code but I am getting error.

Dependent class is invalid and needs recompilation: Class BatchControllerQueingCalls : Constructor not defined: [schedulerQueingCalls].Constructor()

global class schedulerQueingCalls implements schedulable{
    global String sObjectName;
    
    public schedulerQueingCalls(String objName){
        this.sObjectName = objName;
    }
    global void execute(SchedulableContext sc){
        BatchControllerQueingCalls getRecs = new BatchControllerQueingCalls(''+sObjectName);
        database.executeBatch(getRecs);
    }
}

}

if we do the same in a Batch controller, it is working fine without any issues.

Also, how the global variable values passes to Execute method in scheduler..

I have a situation where I need to pass a string to schedulable controller from batch or any apex controller. I see that we can do it using public constructor in schedulable implementation. Please let me know how can I pass a String parameter to schedulable controller. I tried below code but I am getting error.

Dependent class is invalid and needs recompilation: Class BatchControllerQueingCalls : Constructor not defined: [schedulerQueingCalls].Constructor()

global class schedulerQueingCalls implements schedulable{
global String sObjectName;

public schedulerQueingCalls(String objName){
    this.sObjectName = objName;
}
global void execute(SchedulableContext sc){
    BatchControllerQueingCalls getRecs = new BatchControllerQueingCalls(''+sObjectName);
    database.executeBatch(getRecs);
}

}

if we do the same in a Batch controller, it is working fine without any issues.

Also, how the global variable values passes to Execute method in scheduler..

I have a situation where I need to pass a string to schedulable controller from batch or any apex controller. I see that we can do it using public constructor in schedulable implementation. Please let me know how can I pass a String parameter to schedulable controller. I tried below code but I am getting error.

Dependent class is invalid and needs recompilation: Class BatchControllerQueingCalls : Constructor not defined: [schedulerQueingCalls].Constructor()

global class schedulerQueingCalls implements schedulable{
    global String sObjectName;
    
    public schedulerQueingCalls(String objName){
        this.sObjectName = objName;
    }
    global void execute(SchedulableContext sc){
        BatchControllerQueingCalls getRecs = new BatchControllerQueingCalls(''+sObjectName);
        database.executeBatch(getRecs);
    }
}

if we do the same in a Batch controller, it is working fine without any issues.

Also, how the global variable values passes to Execute method in scheduler..

Source Link
AshSFcloud
  • 183
  • 5
  • 32

How to define a constructor and pass parameters to schedulable controller

I have a situation where I need to pass a string to schedulable controller from batch or any apex controller. I see that we can do it using public constructor in schedulable implementation. Please let me know how can I pass a String parameter to schedulable controller. I tried below code but I am getting error.

Dependent class is invalid and needs recompilation: Class BatchControllerQueingCalls : Constructor not defined: [schedulerQueingCalls].Constructor()

global class schedulerQueingCalls implements schedulable{
global String sObjectName;

public schedulerQueingCalls(String objName){
    this.sObjectName = objName;
}
global void execute(SchedulableContext sc){
    BatchControllerQueingCalls getRecs = new BatchControllerQueingCalls(''+sObjectName);
    database.executeBatch(getRecs);
}

}

if we do the same in a Batch controller, it is working fine without any issues.

Also, how the global variable values passes to Execute method in scheduler..