• 2 replies
  • Latest Post - ‏2012-08-17T11:59:09Z by nareshnelluri
1 Post

Pinned topic Problem with displaying data using SQL adapter

‏2012-07-11T19:53:04Z |
I am trying to pull data from a local MySQL database using a SQL adapter. When i invoke the adapter using Eclipse > Run As > Invoke Worklight Procedure, it displays what I expect, a JSON object with a boolean value and an array of data.

However, I want to display this data on a page in my app. I tried using the WL.Server.invokeProcedure(invocationData)function in my JavaScript file, but once it reaches this line, the program breaks and does not invoke the procedure. I've also tried WL.Client.invokeProcedure() but it doesn't work as well.

I have my invocationData declared like:

var invocationData = {adapter : adapter1, procedure : procedure1}

any ideas?! Thank You in advance
  • AntonAleksandrov
    22 Posts

    Re: Problem with displaying data using SQL adapter

    You need to specify adapter name and procedure name as strings:

    var invocationData = {adapter : 'adapter1', procedure : 'procedure1'}

    Also, you need to specify the callback functions that will receive the server response and process it.
    See training module 6 -
  • nareshnelluri
    2 Posts

    Re: Problem with displaying data using SQL adapter

    follow this it may help u...........

    function getEmpdetails(userid)

    // Invocation data details
    var invocationData = {
    // Adapter to invoke
    adapter: 'myadapter',
    // Procedure to invoke
    procedure: 'procedure1',
    parameters: userid

    // Invoke procedure
    WL.Client.invokeProcedure(invocationData, {
    // On success callback
    onSuccess : onSuccess,
    // On failure callback
    onFailure : onFail,
    // timeout
    timeout : 30000


    function onSuccess (result) {

    for(var i=0; i<result.invocationResult.resultSet.length; i++){
    var message1='account id:'+result.invocationResult.resultSet[i].ACCOUNTID;
    var message2='account type:'+result.invocationResult.resultSet[i].ACCOUNTTYPE;
    $("#res").append(message1,message2+ "



    function onFail (error) {

    function onInSuccess (result) {
    alert('inserted successfully');