function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Batch Apex Winter 10



I was under the impression that Batch APEX will be released for all in Winter 10. I've tried to implement the examples but get a insufficient priviliges error.



Do I need to request for the feature to be switched on ?



Fredrick - can you share your class to this thread?  All organizations were enabled as part of the winter '10 release.

Hi Sure,


here's my class


global class KPIBuilder implements Database.Batchable<Sobject>{
    Purpose:The purpose of the class is to generate the KPI measures on a monthly basis
    global final String Query;
    global final Date kpiDate;
    global final String IntervalType;
    global final String Interval;
    private map<string,KPI_Report__c> mpKPI;
    global Database.Querylocator  start(Database.batchableContext bc) {
    // Get all Job Seeker Case records and associated records required for generating the KPIs
    return Database.getQuerylocator(Query);
    global void execute(Database.BatchableContext BC, sObject[] scope){
        //Iterate through the job seeker cases returned
        KPIGenerator kpi = New KPIGenerator();
        mpKPI = New Map<string,KPI_Report__c>();
        //get all the
        for(sObject s : scope){
            Account jsc = (Account) s;
            //check if the map already contains
            integer kpi1N = kpi.StartRateKPINominator(jsc);
            integer kpi1D = kpi.StartRateKPINominator(jsc);
            System.debug('#### Numerator: ' + kpi1N);
            System.debug('#### Denominator: ' + kpi1D);       
            //place results into Map
    global void finish(Database.BatchableContext BC){}
    global KPIBuilder(String q,Date d){Query=q;kpiDate=d;}
    public class KPIGenerator{
        public KPIGenerator(){
        public Integer StartRateKPINominator(Account jsc){
            integer increment = 0;
            //check if refferral date is 12 days in the past
            // and  Start date = yesterday
            return increment;
        public Integer StartRateKPIDenominator(Account jsc){
            integer increment = 0;
            //check if the refferral date is 12 days in the past
            return increment;
    static testMethod void batchTest(){
        //dp something
        String q='SELECT Id, Name, Ownerid FROM Account';
        Date d = System.Today();
        KPIBuilder kpiB = new KPIBuilder(q,d);
       ID batchprocessid = Database.executeBatch(kpiB);