Class 为什么我不能保存这个SalesForce批处理类?
我目前正在使用更新我对SalesForce的了解 教程15第1课:提供以下代码:Class 为什么我不能保存这个SalesForce批处理类?,class,save,salesforce,apex-code,batch-processing,Class,Save,Salesforce,Apex Code,Batch Processing,我目前正在使用更新我对SalesForce的了解 教程15第1课:提供以下代码: global class CleanUpRecords implements Database.Batchable<Object> { global final String query; global CleanUpRecords (String q) {query = q;} global Database.Querylocator start (Database.Bat
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 });
}
}
但是,无论我使用哪种开发界面,例如Force 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>
或者其他类似的,取决于我如何保存它
然而,在我看来,所需的方法已经存在
缺少什么?准备好沮丧吧。。。只差一个字符 你的班级声明应该是:
global class CleanUpRecords implements Database.Batchable<sObject> {
而不是:
global class CleanUpRecords implements Database.Batchable<Object> {
我尝试了这个数据库。但是,它给了我同样的错误。我认为泛型意味着你可以使用任何对象。但后来,我意识到这是Apex代码。谢谢你的提问-