You need to sign in to do that
Don't have an account?
deva nalisetti
hi all,i got this First error: expecting a colon, found 'closedwon' type plese help on this.
global class batch_example implements Database.Batchable<sobject> {
global Database.QueryLocator start (Database.BatchableContext bc){
return Database.getQueryLocator('select id,closeDate,StageName from Opportunity where StageName!=:closed Won');
}
global void execute(Database.BatchableContext bc,list<opportunity>scope){
for(opportunity op:scope){
op.closeDate=system.today();
}
update scope;
}
global void finish (Database.batchableContext bc){
Messaging.SingleEmailMessage email1=new Messaging.SingleEmailMessage();
string[]toadd=new string[]{'ora0423.nallisetti@gmail.com'};
email1.setToAddresses(toadd);
email1.setSubject('batch completion Alert');
email1.setplainTextBody('Batch job'+bc.getJobId()+ 'is processed successfully');
Messaging.Email[]emails=new Messaging.Email[]{email1} ;
Messaging.sendEmail(emails);
}
}
global Database.QueryLocator start (Database.BatchableContext bc){
return Database.getQueryLocator('select id,closeDate,StageName from Opportunity where StageName!=:closed Won');
}
global void execute(Database.BatchableContext bc,list<opportunity>scope){
for(opportunity op:scope){
op.closeDate=system.today();
}
update scope;
}
global void finish (Database.batchableContext bc){
Messaging.SingleEmailMessage email1=new Messaging.SingleEmailMessage();
string[]toadd=new string[]{'ora0423.nallisetti@gmail.com'};
email1.setToAddresses(toadd);
email1.setSubject('batch completion Alert');
email1.setplainTextBody('Batch job'+bc.getJobId()+ 'is processed successfully');
Messaging.Email[]emails=new Messaging.Email[]{email1} ;
Messaging.sendEmail(emails);
}
}
I tried to save above code which you have posted in Salesforce instance and I haven't received any compile error. Can you please save this code and check if you get any error.
Kindly mark this as best answer if it helps you.
Regards,
Sagar
In SOQL you are using 'closed Won' that's using as a list , but you have not decleare this list and also not fill up value , so it's shwoing error not found.
Please let me know if you have any assistanse..
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
The query you have used in inappropriate. The closed won should be within single quotes . Please try with the below query.
Database.getQueryLocator('select id,closeDate,StageName from Opportunity where StageName != \'closed Won\'').
Thanks,
Dhirendra