You need to sign in to do that
Don't have an account?
Rick Rossi
Batch Class Variable Question
Hello!
I am trying to do a mass update of all account emails to "testing.com"
however I am getting an error message saying my variable does not exist. This is my class.
global class BatchUpdateAccountField implements Database.Batchable <SObject>{
global Database.QueryLocator start (Database.BatchableContext bc)
{
return Database.getQueryLocator('SELECT name from Account');
}
global void execute(Database.BatchableContext bc, List<Account> acList)
{
for(Account ac :acList)
{
ac.email = ac.email + ' Testing.com';
}
update acList;
}
global void finish(Database.BatchableContext bc)
{
System.debug('>>>Finish');
}
}
Any help would be great!
I am trying to do a mass update of all account emails to "testing.com"
however I am getting an error message saying my variable does not exist. This is my class.
global class BatchUpdateAccountField implements Database.Batchable <SObject>{
global Database.QueryLocator start (Database.BatchableContext bc)
{
return Database.getQueryLocator('SELECT name from Account');
}
global void execute(Database.BatchableContext bc, List<Account> acList)
{
for(Account ac :acList)
{
ac.email = ac.email + ' Testing.com';
}
update acList;
}
global void finish(Database.BatchableContext bc)
{
System.debug('>>>Finish');
}
}
Any help would be great!
You are getting this error because there is no standard email field in account object. First create custom email field then you can take reference from this below code and you can change the execute method as you like:-
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
If you are using any other field also in execute method then you have to include that field as well in query to avoid this type of error.
Thanks!