I am new to Salesforce. So a help is required from you guyz.

I want to write a Batch Apex, where I want to update some value of Account (lets say Name).

and then from before trigger I have to call this Batch.

How to achieve this??

A help would be very appreciable.

Batch I have written so far

   global class AccUpdate implements Database.batchable<sObject>{ 

   global Database.QueryLocator start(Database.BatchableContext bc) {
    return Database.getQueryLocator('SELECT Id FROM Account');

   global void execute(Database.BatchableContext bc, List<Account> scope) {
       List<Account> Scope1 = [SELECT Id, Name FROM Account];
       for(Account a : scope1){ 
           a.Name = 'Demo Account1'; 
       update Scope1; 
   global void finish(Database.BatchableContext info){     

Now I want to write a before trigger and I want to call this batch .

How to do that??

  • It may be more meaningful to explain what you're trying to achieve and how to do that. Could you explain why you want to kick of a batch from a before trigger context ? Jan 23, 2014 at 8:14
  • @user5442 - I have to echo the comments from @Sdry : why do you require the before trigger (instead of the after trigger)? As you may well know, the Id field is null in the before trigger and yet you reference Id in your start and execute methods( SELECT Id ... ).
    – max
    Jan 23, 2014 at 16:01

1 Answer 1


There are many documents available online. few of things are:



  • How to call the batch class from before trigger???
    – user5442
    Jan 23, 2014 at 7:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .