0

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>
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
user3305763
  • 59
  • 10
  • 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 Mar 26 '14 at 14:01
  • 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 Mar 26 '14 at 14:28
  • Could you describe what is being returned in the 'result' object, please? – eabe Mar 26 '14 at 20:20
  • 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 passed – user3305763 Mar 27 '14 at 05:30
  • @user3305763, what is the contents of result? Right-click the adapter and select Run As > Invoke Worklight procedure. Edit the question. – Idan Adar Mar 30 '14 at 14:36

1 Answers1

0

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.

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89