English 中文(简体)
在所有批次执行后发送含有持续数据的电子邮件时发布
原标题:Issue when sending an Email that contains persistent data after all batches execute

当试图发送带有我所制作批量结尾的批次错误的电子邮件时,我遇到了一个问题。 问题是, 我的输出列表总是由于某种原因被清除, 即使它是一个静态列表。 当我发送一份包含每批次错误的电子邮件时, 电子邮件会发送每批次错误的错误, 并且产出列表还没有被清除, 但是当我尝试在所有批次结尾发送一份电子邮件时, 输出列表会被清除。 我无法在创建批次类中的任何地方清除输出列表, 我只是不断在数据库中添加错误和其他信息 。 是否有办法可以这样做( 在每批次有全部错误的所有批次的批次的末端发送一个邮件)?

// 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

最佳回答

为了解答我创建了一个自定义对象, 我用它来存储值, 然后在完成方法中检索信息。 这也会帮助我存储错误, 并在未来跟踪问题, 我安排了一个清洁功能, 每两周运行一次, 来处理多余的数据 。

我向销售部提起了FATAL_ERROR一案,但尚未得到答复。

问题回答

暂无回答




相关问题
Salesforce - Populate text are from drop down selection

I have a picklist with three values and a text area that has three values as well, but I would like to correlate one value from the picklist with one value of the text area. Any thoughts as on how I ...

Setting Timeout value for Salesforce Web Service/API

The API for Salesforce is a web service, you set it up by downloading a WSDL file from Salesforce and adding the WSDL to your .NET project. But I can t find anywhere to set the Timeout value. ...

Salesforce Custom Objects

Hi I am trying to create a Custom Object in Salesforce.com Developer Edition, because I would then like to use this Custom Object in a New Custom Tab say "Properties". Properties tab will contain ...

热门标签