当试图发送带有我所制作批量结尾的批次错误的电子邮件时,我遇到了一个问题。 问题是, 我的输出列表总是由于某种原因被清除, 即使它是一个静态列表。 当我发送一份包含每批次错误的电子邮件时, 电子邮件会发送每批次错误的错误, 并且产出列表还没有被清除, 但是当我尝试在所有批次结尾发送一份电子邮件时, 输出列表会被清除。 我无法在创建批次类中的任何地方清除输出列表, 我只是不断在数据库中添加错误和其他信息 。 是否有办法可以这样做( 在每批次有全部错误的所有批次的批次的末端发送一个邮件)?
// Class BusinessRules
//method to create cases has the following
CreationBatch cBatch = new CreationBatch();
cBatch.caseList = cList; //list of cases
ID batchprocessid = Database.executeBatch(cBatch,5);
创建批次类有以下内容:
static List<String> outputList = new List<String>();
// The execute method
global void execute(Database.BatchableContext BC, List<Case> scope){
//creates cases and insert them to database then runs this
finally{
GetErrorsFromBatch();
//commented this because I want to send one email at the end of all batches
// when this one was here I used to get multiple emails with the error msgs
//sendBatchEmail();
}
}
// adds error to output list
global void GetErrorsFromBatch(){
....
//for each db error
outputList.add(error);
....
}
global void finish(Database.BatchableContext BC){
// sends the email
// when I put this here I get one email at the end but the outputList is empty
sendBatchEmail();
}
我还尝试将产出列表(公共静态)移到商务规则类, 并添加每批的数值, 但奇怪的是,当我想发送电子邮件时,
<强 > EDIT 强 >
I tried using this global class CaseCreation implements Database.Batchable<sObject>, Database.Stateful
But now I get this error FATAL_ERROR|Internal Salesforce.com Error