You need to sign in to do that
Don't have an account?

Executing the batch class
Hi,
I am new to salesforce, Please help me how to execute this batch class.
Thanks in Advance.
global class AccountBatch implements Database.batchable<sobject>
{
global database.querylocator start(database.batchablecontext bc)
{
string query = 'select id, name from Account';
return database.getquerylocator(query);
}
global void execute(database.batchablecontext bc, list<account>scope)
{
list<account> acc= new list<account>();
for(account a:acc)
{
a.name= 'Mr' +a.name;
acc.add(a);
}
update acc;
}
global void finish(database.batchablecontext bc)
{
}
}
I am new to salesforce, Please help me how to execute this batch class.
Thanks in Advance.
global class AccountBatch implements Database.batchable<sobject>
{
global database.querylocator start(database.batchablecontext bc)
{
string query = 'select id, name from Account';
return database.getquerylocator(query);
}
global void execute(database.batchablecontext bc, list<account>scope)
{
list<account> acc= new list<account>();
for(account a:acc)
{
a.name= 'Mr' +a.name;
acc.add(a);
}
update acc;
}
global void finish(database.batchablecontext bc)
{
}
}
play for look on scope not acc Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
All Answers
Type the following Apex code:
AccountBatch batch = new AccountBatch();
Database.executeBatch(batch);
Click Execute
for reference : https://help.salesforce.com/articleView?id=000171199&language=en_US&r=https%3A%2F%2Fwww.google.co.in%2F&type=1
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
http://sfdcmonkey.com (http://sfdcmonkey.com )
Goto apex class and click schedule apex button then you can see this class.
You can choose to schedule at a preferred date and time.
Please let me know if it helps.
Please don't forget to mark this as solved if it's resolved.
Thanks,
Saravana
After executing the calss still account names remain the same.It doesnt change.
Thanks
Smitha
play for look on scope not acc Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
It executed fine.Thank you very much.
Can you tell me what is the use of scope ?
Thanks,
Smitha
Hope its helps you to understand
Thanks
Thank you so much.