You need to sign in to do that
Don't have an account?
ApexNewb2012
Error Code but NO ID Cannot_Update_Current_Lead in XML response
HEllo I was wwondering how i can get my XML response from Salesforce to Include the Id where it errors out?
I get the Id when it is a success for each success but not for errors? I am running my process through Pervasive..
Database.SaveResult hold Ids only when records process successfully.It is really strange but there is a work around for this problem. According to salesforce documentation the order of list which is passed to the DML operation would be same in the response.So you can see my sample code below to solve this issue.
Database.SaveResult [] accountsProcessed = Database.update (listActToUpdate,false);
for (Database.SaveResult result : accountsProcessed) {
Integer index =0;
System.Debug('*********Result'+result);
if (!result.isSuccess()) {
string error='';
Database.Error[] errs = result.getErrors();
for(Database.Error err : errs){
error+= err.getMessage();
}
// because result.getId return null in case of error but according to salesforce order of records in save result is same as passed in parameter so I am using another technique
Trigger.newMap.get(mapOfAccountIdWithContId.get(listActToUpdate[index].Id)).addError(error);
}
index++;
}
See Dom.Document in apex to see how add value in XML . Not sure but might be it would help.