I'm trying to submit for approval using java code. It's seems working, but the issue is when the submit failed (E.g. record doesn't met the entry criteria), I cannot get clear message of the reason.
According to the documentation in SF should use getErrors().toString(), but this give
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_process.htm
Java Code:
ProcessSubmitRequest[] l_processSubmitRequest = new ProcessSubmitRequest[totalRecords];
for(int i = 0; i < totalRecords; i++){
ProcessSubmitRequest processSubmitRequest = new ProcessSubmitRequest();
processSubmitRequest.setComments(comment);
processSubmitRequest.setObjectId(l_Records.get(i).getId());
l_processSubmitRequest[i] = processSubmitRequest;
}
//Submit all records for approval and check the results
ProcessResult[] l_processResult = connection.process(l_processSubmitRequest);
for(ProcessResult processResult : l_processResult){
if(!processResult.isSuccess()){
errorMsg += "\n\nMessage when using getErrors()[0].getMessage(): " + processResult.getErrors()[0].getMessage();
errorMsg += "\n\nMessage when using getErrors().toString(): " + processResult.getErrors().toString();
}
}
Output is:
Message when using getErrors()[0].getMessage(): <messaging:emailTemplate> cannot contain <apex:pageBlock>.
Message when using getErrors().toString(): [Lcom.sforce.soap.partner.Error;@49e5f737