We are calling a rest datasource where the callback function is not called if the STATUS CODE(status) is other than 0
{
response:
{
data:[
{
columnTwo:null,masterScreenName:null,select:"false",addModifyRevertAuthorize:null
,rowOperationalFlag:null,operationFlag:null,SQLTypeName:null,errorCode:null,warningMessageList:[],
errorParams:null,tableName:null
}
],startRow:0,endRow:50,totalRows:51,[B]status:0[/B]
}
}
The call back is successfully executed when the status code is 0. Below is the response with status code other than 0.
{response:{data:null,errors:[["SM0001-Record Already Exists"]],[B]status:-4[/B]}}
Below is the custom class code written with error handler
registerDBFCRestDataSource : function() {
isc.defineClass("DBFCRDS", "RestDataSource");
isc.DBFCRDS.addMethods({
handleError : function(response, request) {
if (response && response.errors) {
if (response.errors.ISE) {
isc.say(isc.echoAll(response.errors));
}
}
return this.Super('handleError', "");
},
transformResponse : function(dsResponse, dsRequest, xmlData) {
this.Super('transformResponse', arguments);
},
getDataURL : function() {
var url = this.Super('getDataURL', arguments);
if (url !== undefined) {
if (url.startsWith('http')) {
return url;
}
if (url.startsWith(db.fc.app.App.getContext() + '/')) {
return url;
} else {
return db.fc.app.App.getContext() + url;
}
}
}
});
isc.DBFCRDS.addProperties({
dataFormat : "xml",
autofetch : false,
sendMetaData : true
});
}
Below is the call from code to update/fetch data
this.addModifyRevertAuthorizeDS.fetchData(args,
function(dsResponse, data){
[B]// control does not reach here in case of status other than 0[/B]
if(localThis.addModifyRevertAuthorize != 'C'){
localThis.clearPage();
}
if(dsResponse.status != 0) {
localThis.errorMessages(dsResponse.errors[0]);
if(localThis.addModifyRevertAuthorize == 'C'){
localThis.addModifyRevertAuthorize = localThis.tempAddModifyRevertAuthorize;
Form1.setValue('formDisabled',false);
}else{
localThis.addModifyRevertAuthorize = '';
}
} else if(data != ''){}
},{prompt:i18n['db.fc.system.stateMaster.SavingRecords']}
);