0
votes

I created a SQL adapter in worklight 6.1 with procedures for offline JSONStore.

I am able to call the adapter procedure using the below function, followed by execution of query.
But I am not able to make use of the invocation result.

function aa() {
    try{
        var result=WL.Client.invokeProcedure({
        adapter : 'DB2',
        procedure : 'getDB2',
        parameters : [x,y]
        invocationContext:{}
    }, {
        onSuccess : function(result) {
            alert("login Success"); WL.Logger.debug("Retrieve success" +  JSON.stringify(result));

            //THIS IS NOT WORKING.I CANT SEE THE RESULT IN MY BROWSER
            displayFeeds(result.invocationResult.resultSet);
            document.getElementById("div4").innerHTML = result.invocationResult.resultSet[1].NAME;
       },
       onFailure : function(result){alert("login Failure");}
       });
    }
    catch(e) {
        alert("ERROR::"+e);
    }
}

function displayFeeds(items){
     var ul = $('#itemsList');
     for (var i = 0; i < items.length; i++) {
          var li = $('<li/>').html(items[i].PIN);
          li.append($('<li/>').html(items[i].NAME));
          li.append($('<li/>').html(items[i].DOB));
          li.append($('<hr>'));
          ul.append(li);
    }
}

HTML:

   ...
   ...
   <ul data-role="listview" id="itemsList" data-inset="true"> </ul>  
   <a href="#" data-role="button" id="button" onclick = "aa()">Show Name List</a>

   <div id="div4"></div>
1
Status 200 is not the only successful status. For example, Status 202 is successful (kind of, it's the server saying "I understood what you want me to do"), and Status 204 is successful (server saying "I've done what you asked me to do").gnasher729
While returning invocation result from adapter procedure,status code and JSON object gets passed to onSuccess() function..I am not able to see the result in my browser..user3305763
Could you describe what is being returned in the 'result' object, please?eabe
Thanks Idan Adar..while opening the worklight JSON store,it says"Adapter returned isSuccessful=true, but the status code was not 200"..that means only resultSet object gets passeduser3305763
@user3305763, what is the contents of result? Right-click the adapter and select Run As > Invoke Worklight procedure. Edit the question.Idan Adar

1 Answers

0
votes

Looks like there are 3 of you, probably in the same team, asking the same question - even using the same code snippets ... is this true?


See the second question above.
I suggest implementing it as done there; it works.