You need to sign in to do that
Don't have an account?
penchala raju
can any one solve this batch apex program
global class customerbatch implements Database.Batchable<sobject>
{
public String myname;
global customerbatch(String myname)
{
this.myname=myname;
}
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator('select id,AType__c from Customer__C where name='+myname);
}
global void execute(Database.BatchableContext bc,list<customer__c> scope)
{
list<Customer__c> cust=new List<Customer__c>();
for(Customer__c c:cust)
{
c.AType__c='saving';
cust.add(c);
}
update cust;
}
global void finish(Database.BatchableContext bc)
{
Messaging.singleEmailMessage myemail=new Messaging.singleEmailMessage();
String[] toadd=new String[]{'penchalaraju7@gmail.com'};
myemail.setToAddresses(toadd);
myemail.setSubject('my notification');
messaging.sendEmail(new messaging.Email[]{myemail});
}
}
{
public String myname;
global customerbatch(String myname)
{
this.myname=myname;
}
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator('select id,AType__c from Customer__C where name='+myname);
}
global void execute(Database.BatchableContext bc,list<customer__c> scope)
{
list<Customer__c> cust=new List<Customer__c>();
for(Customer__c c:cust)
{
c.AType__c='saving';
cust.add(c);
}
update cust;
}
global void finish(Database.BatchableContext bc)
{
Messaging.singleEmailMessage myemail=new Messaging.singleEmailMessage();
String[] toadd=new String[]{'penchalaraju7@gmail.com'};
myemail.setToAddresses(toadd);
myemail.setSubject('my notification');
messaging.sendEmail(new messaging.Email[]{myemail});
}
}
customerbatch cb=new customerbatch(myname);
Database.executeBatch(cb,5);
it showing variable name does not exist
String myname = 'someText';
Replace someText with the name you are wanting to use in the batch.
customerbatch cb=new customerbatch('TestName'); // Please add Name here
Database.executeBatch(cb,5);
customerbatch cb=new customerbatch('TestName'); // Please add Name here
Database.executeBatch(cb,5);
Please make this as best solution if this will help you.
Thanks
Amit Chaudhary
Please check all debug log. Check Query and Check how many record are comming after query.
NOTE:- According to query if you are passing name then only one record will come.
for exp:- if you are passing 'raju' then only one record will come
select id,AType__c from Customer__C where name='raju';
After executing the batch job. Please check record once batch job will completed.