You need to sign in to do that
Don't have an account?

View the 'Return' Results in Apex
We have a class that handles lead inserts from a 3rd party source. Within the class, we have created an inner class called LeadDetailResponseData which handles the lead insert responses.
global class LeadDetailResponseData {
public Integer MessageId;
public String Status;
public String ErrorMessage;
}
We have then created a list of 'LeadDetailResponseData' types that will store the results of the lead import:
List<LeadDetailResponseData> ResponseMsg = new List<LeadDetailResponseData>();
Upon insertion, if there are any errors, it is getting stored to the ErrorMessage variable. The message then gets added to the list of Lead Detail Responses. Note that l is an instance of a Lead object and lr is an instance of the LeadResponseDetail class.
try {
l.setOptions(dmo);
insert l;
} catch (DmlException e) {
lr.Status = '-1'; //Insert Error
lr.ErrorMessage = e.getMessage();
}
ResponseMsg.Add(lr);
return ResponseMsg;
My question is where does the Return go? Is it returned to the process that's calling this class? Or is it stored somewhere within the instance of Salesforce.
Any feedback is much appreciated.
Thanks.
global class LeadDetailResponseData {
public Integer MessageId;
public String Status;
public String ErrorMessage;
}
We have then created a list of 'LeadDetailResponseData' types that will store the results of the lead import:
List<LeadDetailResponseData> ResponseMsg = new List<LeadDetailResponseData>();
Upon insertion, if there are any errors, it is getting stored to the ErrorMessage variable. The message then gets added to the list of Lead Detail Responses. Note that l is an instance of a Lead object and lr is an instance of the LeadResponseDetail class.
try {
l.setOptions(dmo);
insert l;
} catch (DmlException e) {
lr.Status = '-1'; //Insert Error
lr.ErrorMessage = e.getMessage();
}
ResponseMsg.Add(lr);
return ResponseMsg;
My question is where does the Return go? Is it returned to the process that's calling this class? Or is it stored somewhere within the instance of Salesforce.
Any feedback is much appreciated.
Thanks.
Yes you are on right track it returned to the process that's calling this class method.Process will get the list of Errors i.e ResponseMsg.
Since the class is being invoked by a third party, I am not able to see the error message generated by the call.
Thanks.
if possible share working code for Class.