You need to sign in to do that
Don't have an account?
sfdc dev 2264
Constructor not defined: in schedulable class
Hi,
I am hyaving a scheduler class for my batch class which i am getting the following error
Error: Compile Error: Constructor not defined: [ContractBatchTriggerHandler].<Constructor>() at line 5 column 43
help me what i am doing wrong here
thanks
I am hyaving a scheduler class for my batch class which i am getting the following error
Error: Compile Error: Constructor not defined: [ContractBatchTriggerHandler].<Constructor>() at line 5 column 43
MY SCHEDULER CLASS : global class ContractBatchTriggerHandler_Schedular implements Schedulable { global void execute(SchedulableContext sc) { ContractBatchTriggerHandler opb = new ContractBatchTriggerHandler(); Database.executeBatch(opb,100); } }
MY BATCH CLASS : global class ContractBatchTriggerHandler implements Database.Batchable<sObject> { Set<Id> contractIdSet = new Set<Id>(); // Constructor will take set of new Contract IDs global ContractBatchTriggerHandler (Set<Id> contractIdSet){ this.contractIdSet = contractIdSet; } global Database.QueryLocator start(Database.BatchableContext bc) { // Query all Contract records that were in Trigger.new return Database.getQueryLocator([SELECT Status__c, Account__c FROM Contract__c WHERE Id IN :contractIdSet]); } // The execute method will call three methods global void execute(Database.BatchableContext bc, List<Contract__c> scope) { ContractfieldsupdateonAccount(scope); contractcommencementdate(scope); contractexpirydate(scope); }
help me what i am doing wrong here
thanks
All Answers
You need to pass set of contarct id in Constructor , becuse in your code you have wrriten Constructor with parameter .
Add folllowing line in your sheduler calss
Thanks
global class ContractBatchTriggerHandler_Schedular implements Schedulable {
global void execute(SchedulableContext sc) {
Set<id> contractId = new Set<id>();
ContractBatchTriggerHandler opb = new ContractBatchTriggerHandler(contractId);
Database.executeBatch(opb,100);
}
}
or do i have to add the query in set<id> contract id ?
let me know
thanks
please correct it
Thanks
global class ContractBatchTriggerHandler_Schedular implements Schedulable {
global void execute(SchedulableContext sc) {
Set<id> contractId = new Set<id>();
ContractBatchTriggerHandler opb = new ContractBatchTriggerHandler(contractId);
Database.executeBatch(opb,100);
}
}
or do i have to add the query in set<id> contract id ?
let me know
thanks
"contractId"
let me know how to add it pls
thanks
Error: Compile Error: Initial term of field expression must be a concrete SObject: List<Contract__c> at line 7 column 16
global class ContractBatchTriggerHandler_Schedular implements Schedulable {
list<Contract__c>Con = new list<Contract__c>();
global void execute(SchedulableContext sc) {
Set<id> contractId = new Set<id>();
for(Contract__c c :Con )
{
contractId.add(Con.id);
}
ContractBatchTriggerHandler opb = new ContractBatchTriggerHandler(contractId);
Database.executeBatch(opb,100);
}
}
let me know what happens?
try this