3 Replies Latest reply on Dec 21, 2016 1:21 PM by Timothy Vermeiren

    WDC working in Simulator, but not in Tableau

    Timothy Vermeiren

      Hi All,

       

      I'm attempting to write a WDC that downloads data from Slack, that is already saved as a json somewhere on the web (for a reason). So I'd imagine this should be quite a basic scenario.

       

      Now I'm not sure what is happening, but it seems the WDC works in the Simulator, and is able to return data. It does take a few seconds after clicking the "Fetch Table Data" button, but data comes in. Although this makes me wonder if the issue is related to a problem with the (a)synchronicity of this process. Moreover, when using the WDC in Tableau, it shows the correct columns, but when going to a sheet, it jumps there immediately, seemingly without extracting data. And sure enough, there are always 0 rows in the dataset.

       

      Any idea what's wrong with the code, and how to get it to work "in the right order"? The code is attached to this post.

       

      Thanks in advance!

       

      Timothy

        • 1. Re: WDC working in Simulator, but not in Tableau
          Patrick A Van Der Hyde

          Hello Timothy,

           

          I am checking into this one to try and locate some help for you.   Did you already find a solution or is this still an issue?

           

          Patrick 

          1 of 1 people found this helpful
          • 2. Re: WDC working in Simulator, but not in Tableau
            Samm Desmond

            Hi Timothy,

             

            Thanks so much for posting your code; I took a look and I think I see your problem. You were right to suspect the asynchronous behavior because that's the issue in your getData method.

             

            Below is an outline of the getData method, the first thing it does is kick off a $.getJSON request which takes in a callback function. The next thing it does is call doneCallback which tells Tableau the connector has finished gathering data. Since the getJSON request runs asynchronously, the callback function which actually returns data to Tableau (by calling table.appendRows(tableData)) runs after the call to doneCallback so Tableau is ignoring the appendRows call. This likely works in the simulator because the simulator is still listening for calls to table.appendRows, but inside of Tableau that is ignored.

             

            Luckily, the fix should be very simple: Just move the doneCallback() line immediately after table.appendRows inside of the callback to $.getJSON function. I've attached a modified version of your js here

             

             

            myConnector.getData = function (table, doneCallback) {

                $.getJSON(fetchURL, function(resp) {

            // ......................................

                      table.appendRows(tableData);

              });

             

              doneCallback();

            };

            1 of 1 people found this helpful
            • 3. Re: WDC working in Simulator, but not in Tableau
              Timothy Vermeiren

              Hi Patrick, Samm,

               

              Thanks for your helpful answers!

               

              Samm, that's indeed what I had to change! I can't believe it - I thought I'd tried every possibility but that one I must have skipped... So obvious.

               

              Thanks a ton!

               

              Timothy