8 Replies Latest reply on Jan 27, 2016 10:52 AM by Martin Seifert

    WDC: weird (unclear) error message - Uncaught Looks like the WDC is calling a tableau function before tableau.init() has been called.

    Martin Seifert

      Hi all!

       

      I'm working on a Web Data Connector to a REST API. The (weird) error code appears when I run the connector without the Simulator. Everything works fine when I run my WDC in the simulator (part of the SDK). But without the simulator the console.log spits out the error(s):

       

       

      Uncaught Looks like the WDC is calling a tableau function before tableau.init() has been called.

        _sendMessage @ tableauwdc-1.1.0.js:95

        tableau.submit @ tableauwdc-1.1.0.js:24

        (anonymous function) @ myConnector.html:155

        m.event.dispatch @ jquery.min.js:3

        r.handle @ jquery.min.js:3

      Uncaught Looks like the WDC is calling a tableau function before tableau.init() has been called.

        _sendMessage @ tableauwdc-1.1.0.js:95

        tableau.abortWithError @ tableauwdc-1.1.0.js:40

        window.onerror @ tableauwdc-1.1.0.js:172

       

       

      I checked the .js Tableau is hosting, but don't quite understand the error.

       

      I tried to use the .js on public instead of online (see https://community.tableau.com/thread/179254), didn't work.

       

      Also see: https://community.tableau.com/thread/189948 where Chris seems to have found the reason for this, but I don't quite get it

       

       

      Can anyone provide information on what is going on here? Do I need to call some init() function somewhere? I tried calling tableau.initCallback() on several positions without success...

       

       

      Here is some (skeleton) code:

       

      <html>

      <meta http-equiv="Cache-Control" content="no-store" />

      <head>

        <title>myWDC</title>

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>

        <script src="https://online.tableau.com/javascripts/api/tableauwdc-1.1.0.js" type="text/javascript"></script>

        <script type="text/javascript">

        (function() {

       

          function buildUri(startDate, endDate) {

            // Helper function to build the URI, works fine

            // ...

            return uri;

          }

           

          var myConnector = tableau.makeConnector();

       

       

          myConnector.getColumnHeaders = function() {

            // Defining fields names used in Tableau

            // ...

            tableau.headersCallback(fieldNames, fieldTypes);

          }

           

          myConnector.getTableData = function(lastRecordToken) {

            var dataToReturn = [];

            var hasMoreData = false;

       

       

            // Get parameter values and put URI in object 'connectionUri'

            // ...

             

            // Get the data with jQuery AJAX call

            var xhr = $.ajax({

              url: connectionUri,

              // Some more options here

              // ...

              success: function (data) {

                // Some magic here, works fine, too

                // ...

              },

              error: function (xhr, ajaxOptions, thrownError) {

                // If the connection fails, log the error and return an empty set.

                tableau.log("Connection error: " + xhr.responseText + "\n" + thrownError);

                tableau.abortWithError("Error while trying to connect to the data source.");

              }

            });

          }

         

          tableau.registerConnector(myConnector);

         

        })();

       

        $(document).ready(function() {

          $("#buttonSubmit").click(function() {

            var _User = $('#inputUser').val().trim();

            var _Pass = $('#inputPass').val().trim();

            if (_User && _Pass) {

              tableau.connectionName = 'Connection name';

              tableau.username = _User;

              tableau.password = _Pass;

              tableau.submit();

            }

          });

        });

       

        </script>

      </head>

      <body>

        <p>Enter Username: <input type="text" id="inputUser" /></p>

        <p>Enter Password: <input type="text" id="inputPass" /></p>

        <p><p><button type="button" id="buttonSubmit">Get the Data</button></p></p>

      </body>

      </html>

       

      Anonymized error message - Message was edited by: Martin Seifert

       

      Replaced wtPass (see first reply and my answer) with "_Pass" - Message was edited by: Martin Seifert