So I’ve got a custom transformResponse() on a datasource that is looking for errors in the response from an add or update, and it looks like this:
transformResponse: function (dsResponse, dsRequest, data) {
var response = isc.XMLTools.toJS(data);
var isErrorPresent = isc.XMLTools.selectObjects(response, "/error");
if (isErrorPresent != '') {
dsResponse.status = isc.RPCResponse.STATUS_VALIDATION_ERROR;
var message =
isc.XMLTools.selectObjects(response, "/error/message");
if (message && message != '') {
alert(message);
}
var fieldErrors =
isc.XMLTools.selectObjects(response, "/error/fieldErrors");
if (fieldErrors) {
dsResponse.errors = fieldErrors;
}
}
return dsResponse;
}
This works as expected and all fields specified in fieldErrors are flagged as invalid and the error messages are shown. However, the call to updateData() that orginated the request specifies a callback, and that callback expects to work with the updated record. On an error though, that record doesn’t exist, and as a result the callback gets called with basically invalid data.
Is there any way to keep the callback from being triggered when there are errors returned? Part of the this particular issue is that if certain values in the record that I’m working with aren’t set the form is instructed to hide other values until there is a value. So if an error occurs on one of the fields that gets hidden, the user won’t see the problem.