You need to sign in to do that
Don't have an account?
Ajitkumar Pradhan 9
Batch Code not eexcuting
global class BatchJobStatus implements Database.Batchable<sObject>,Database.AllowsCallouts
{
public String query;
global Database.querylocator start(Database.BatchableContext BC){
query = 'Select id, AccountId, Account_Company_Id__c, JobDiva_ID__c, StageName from Opportunity where (JobDiva_ID__c!=null AND StageName ="Lost")';
return Database.getQueryLocator(query);
}
global void start(){
Database.executeBatch(new BatchJobStatus(),100);
}
global void execute(Database.BatchableContext bc, List<Opportunity> oppList){
for (Opportunity opp : oppList) {
if (opp.StageName=='Lost'){
opp.StageName = 'Closed';
}
try{
update oppList;
}
catch(Exception e) {
System.debug(e);
}
}
}
global void finish(Database.BatchableContext bc){
}
}
{
public String query;
global Database.querylocator start(Database.BatchableContext BC){
query = 'Select id, AccountId, Account_Company_Id__c, JobDiva_ID__c, StageName from Opportunity where (JobDiva_ID__c!=null AND StageName ="Lost")';
return Database.getQueryLocator(query);
}
global void start(){
Database.executeBatch(new BatchJobStatus(),100);
}
global void execute(Database.BatchableContext bc, List<Opportunity> oppList){
for (Opportunity opp : oppList) {
if (opp.StageName=='Lost'){
opp.StageName = 'Closed';
}
try{
update oppList;
}
catch(Exception e) {
System.debug(e);
}
}
}
global void finish(Database.BatchableContext bc){
}
}
Hello Ajit,
Try this I hope it will work
All Answers
Hello Ajit,
Try this I hope it will work
Thanks for correction.
My opportunity stage should aslo get update right? according to this code. But its not getting update. Am i missing something could you please help.
Let us know if this will help you
Thanks
Amit
But still my opportunity stage is not getting updated. Do i need to do anything extra?
I have one opportuity which is Lost and it should get updated to Won but not happening.
Thanks
Amit
Database.executeBatch(new BatchJobStatus(),100);
i executed this bydoing Ctrl+E and some Log appeared.
And check any exeption is coming or not
try this