Tag Archives: Apex

Schedule Batch Apex For Every Hour

Batch Class:

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) {
      
        for(Account a : scope) {
            a.Name = a.Name + 'Updated';
        }
        update scope;
    } 
      
    global void finish(Database.BatchableContext bc) {
      
    }
}

Scheduled Class:

global class accountBatchSchedule implements Schedulable{
	global void execute(SchedulableContext sc) {
		//invoke the batch class
        Database.executeBatch(new accountBatch());
    }
}

Execute below code from anonymous window in developer console. This will scheduled the job to run in every hour starting from 12:00 AM.

accountBatchSchedule sc = new accountBatchSchedule();
//Define cron expression
String cronExp = '0 0 * * * ?';
String jobID = System.schedule('Update Account', cronExp, sc);

Related list Button Edit/Delete/View is not working in VF Page on Service Cloud Console

If showHeader="false" in VF Page, the related list Button Edit/Delete/View won’t work on Service Cloud Console.
When showHeader is set to false, some important JS files needed for the service cloud console to function properly will not be loaded, and hence you may see some issues. It is recommended to leave showHeader as true while using in the service cloud console.