简体   繁体   English

ule子:在批处理中提交批处理后捕获失败的Salesforce Upsert记录

[英]mule: Capturing failed Salesforce Upsert record after batch commit in batch processing

I have to upsert large amount of data to opportunities in salesforce. 我必须向销售人员的机会中添加大量数据。 Used batch commit in first batch step. 在第一批步骤中使用了批量提交。 The result of Upsert Bulk is the list of Upsert Result which has success,id,error,fields. Upsert Bulk的结果是Upsert Result列表,其中包含成功,id,错误,字段。

Iterating over this result , to check for failed record (success is false), now I wanted to send the error and the original payload to email. 遍历此结果,以检查失败的记录(成功为假),现在我想将错误和原始有效负载发送到电子邮件。

  1. How do I associate the failed upsert result with the original payload? 如何将失败的upsert结果与原始有效负载相关联?
  2. Does the order of input payload is maintained in the output after batch commit? 批量提交后,输出中是否保持输入有效负载的顺序?

Example : inputpayload :[rec1,rec2,rec3] UpsertResult[success:true,success:false errors:invalid field,success:true] 示例:inputpayload:[rec1,rec2,rec3] UpsertResult [成功:true,成功:false错误:无效字段,成功:true]

I want to send an email saying rec2 has failed due to error invalid field. 我想发送一封电子邮件,说rec2因错误无效字段而失败。

Any help would be highly appreciated. 任何帮助将不胜感激。

The order of salesforce opeation result will be maintained as same as per Input order. Salesforce操作结果的顺序将与输入订单相同。 Store the input in a Hashmap with Id as key and entire input as value, before the batch step. 在批处理步骤之前,将输入存储在哈希表中,以ID作为键,将整个输入作为值。 After the batch step, Iterate over the result and collect the Ids when result has status as false. 批处理步骤之后,遍历结果并在结果状态为false时收集ID。

Now you can easily retrieve failed Id's data from the hashmap, by passing Id. 现在,您可以通过传递ID轻松地从哈希图中检索失败的ID数据。 Code snippet 程式码片段

def inputPayloadForReprocess =[]; def inputPayloadForReprocess = [];

//logic to build error records for reprocess for(int i=0; i < payload.size() ; i++ ){ //逻辑以建立用于重新处理for(int i = 0; i <payload.size(); i ++){
if(payload.get(i).toString().contains("success='false'")){ //check for salesforce failures if(payload.get(i).toString()。contains(“ success ='false'”)){//检查salesforce失败

    inputPayloadForReprocess.add(message.getInvocationProperty("storePayload").get(i));
    break;
}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM