You need to sign in to do that
Don't have an account?
Apex Job... can't execute executeBatch()
Hi,
I tried to execute Database.executeBatch()..But I couldn't.:smileysad:
I'm using Japanese salesforce.com, so I don't know an original error message.
The message means "you don't have a permission. So you can't execute the request. Please ask owner or system administrator.".
I have a permission of system administrator and I made all custom object,Apex Trigger and classes.
Code is very simple:
trigger TestScript on Batch_Script__c bulk (after update) {
//if checkbox is checked, run the script
for (Batch_Script__c bs : Trigger.new) {
if (bs.Test_Script_Run__c == true) {
Job j = new Job();
Database.executeBatch(j);
//update status of Batch Script instance
Batch_Script__c ourBS = new Batch_Script__c (
Id = bs.Id,
Test_Script_Run__c=false,
Test_Script_Last_Run_Date__c=system.today()
);
update ourBS;
}
}
}
global class Job implements Database.Batchable<toTable__c>{
global database.Querylocator start(){
return Database.getQueryLocator([select Name__c,Run_Date__c from fromTable__c]);
}
global void executeBatch(SObject[] ttb){
List<fromTable__c> ftbl = [select Name__c,Run_Date__c from fromTable__c]; List<toTable__c> ttbl = new List<toTable__c>();
for(fromTable__c l : ftbl){
toTable__c ttbc = new toTable__c();
ttbc.Name__c = l.Name__c;
ttbc.Run_Date__c = system.today();
ttbl.add(ttbc);
}
insert ttbl;
}
global void finish(){ }
}
Hi,
Batch- Apex is not by default enabled in all summer 09 orgs, you have to send a request to enable batch Apex, and then only you will be able to use this in your Org.
Regards,
Rajan Jasuja
All Answers
Hi,
Batch- Apex is not by default enabled in all summer 09 orgs, you have to send a request to enable batch Apex, and then only you will be able to use this in your Org.
Regards,
Rajan Jasuja
Hi,
Thank you for your reply.
I'm using developer edition only.
I called support desk, but he didn't ask whether Batch-Apex can be enabled on developer edition:smileysad:
Does anyone have the answer?