2012-03-10 19 views
2

我目前在使用Apex Workbook來刷新我對SalesForce的瞭解。爲什麼我無法保存這個SalesForce Batchable類?

教程#15,第1課:信息下面的代碼:

global class CleanUpRecords implements Database.Batchable<Object> 
{ 
    global final String query; 

    global CleanUpRecords (String q) {query = q;} 

    global Database.Querylocator start (Database.BatchableContext BC) 
    { 
      return Database.getQueryLocator(query); 
    }  


    global void execute (Database.BatchableContext BC, List<sObject> scope) 
    { 
     delete scope; 
     Database.emptyRecycleBin(scope); 
    }  

    global void finish(Database.BatchableContext BC) 
    { 
     AsyncApexJob a = [ 
       SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email 
       FROM AsyncApexJob 
       WHERE Id = :BC.getJobId() 
      ]; 

     // Send an email to the Apex job's submitter 
     // notifying of job completion. 
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
     String[] toAddresses = new String[] {a.CreatedBy.Email}; 
     mail.setToAddresses(toAddresses); 
     mail.setSubject('Record Clean Up Completed ' + a.Status); 
     mail.setPlainTextBody (
       'The batch Apex job processed ' + a.TotalJobItems + 
       ' batches with '+ a.NumberOfErrors + ' failures.' 
       ); 
     Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
    } 

} 

然而,無論哪個開發接口(例如強制IDE,控制檯,安裝)我用,當我試圖挽救這個,我得到:

Multiple markers at this line 
    - File only saved locally, not to server 
    - Save error: CleanUpRecords: Class must implement the global interface method: Iterable<Object> start(Database.BatchableContext) from Database.Batchable<Object>, CleanUpRecords: Class must implement the global interface method: void execute(Database.BatchableContext, LIST<Object>) from 
    Database.Batchable<Object> 

(或等同的,這取決於我如何試圖挽救它。)

然而,在我看來,所需的方法已經在那裏了。

什麼是缺失?

+0

我想這Database.Batchable 。但是,它給了我同樣的錯誤。我雖然泛型意味着你可以使用任何對象。但後來,我意識到這是Apex Code。感謝您的問題。 :-) – 2013-12-13 18:39:47

回答

6

準備沮喪...只有一個字符關閉。

類聲明應該是:而不是

global class CleanUpRecords implements Database.Batchable<sObject> { 

global class CleanUpRecords implements Database.Batchable<Object> { 
+0

很棒!乾杯! – 2012-03-10 17:50:35

相關問題