Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Rest datasource callback function is not called if the STATUS CODE(status) returned other than 0

    We are calling a rest datasource where the callback function is not called if the STATUS CODE(status) is other than 0
    Code:
    {
            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.
    Code:
    {response:{data:null,errors:[["SM0001-Record Already Exists"]],[B]status:-4[/B]}}

    Below is the custom class code written with error handler
    Code:
    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

    Code:
    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']}
                );
    Last edited by vikashdwi; 21 Jun 2019, 04:29.

    #2
    Please read the Error Handling overview. This is by design and well documented.

    Comment


      #3
      I've gone through the documents in case of API error scenario no where mention the call back function should not be called because it is always called in case of API success. Please help us if you have any clue, It was working fine in smartclient version-9.

      Comment


        #4
        Seriously, when we point you straight to a specific doc, you are required to read it as a condition of your support contract - you are not allowed to just ask questions without reading docs, that's not how the support process works.

        So again go back and read the Error Handling overview. The fact that your callback will not be called for a negative status code is well documented, and is by design, and the same overview explains how you can get your callback called if you want. And it was the same in SmartClient 9 as well.

        Also you have an invalid call to Super. Second argument can either be an Array or the native arguments object. You are inexplicably passing an empty string, that's not valid.

        Comment

        Working...
        X