6 Replies Latest reply on Jun 13, 2014 12:58 PM by keith.thompson.0

    Error: tableauSoftware is undefined

    keith.thompson.0

      I am trying to duplicate the example for the Javascript API located here. When I do, I get an error that tableauSoftware is undefined. I checked our instance of Tableau Server to see that http://myServer/javascripts/api/tableau_v8.js is present. Can someone explain why it can't recognize the tableauSoftware object? I have already tried the solution mentioned here.

       

      Here is my full code. My goal is ultimately to iterate through the filter values and create PDFs of the view for each value (around 300). This is just a test with a dummy variable called providers to see if I can get it working for 2 values.

       

      <html>

      <head>

        <link rel="stylesheet" type="text/css" href="style.css">

        <script language="javascript" type="text\javascript" src="http://myServer/javascripts/api/tableau_v8.js"></script>

        <script language="javascript" type="text\javascript" src="http://myServer/javascripts/api/viz_v1.js"></script>

        <script language="javascript" type="text\javascript" src="jspdf.js"></script>

        <script>

        var viz;

        var providers = ["prov1","prov2"];

        window.onload = function() {

        var div = document.getElementById("left");

        var url = "http://myServer/views/myView;

        var options = {

        width: div.offsetWidth,

        height: div.offsetHeight,

        hideTabs: true,

        hideToolbar: true,

        onFirstInteractive: function () {

        workbook = viz.getWorkbook();

        activeSheet = workbook.getActiveSheet();

        }

        };

        viz = new tableauSoftware.Viz(div, url, options);

        }

        function createPdf() {

        var doc = new jsPDF("landscape","mm","letter");

        var workbook = viz.getWorkbook();

        var activeSheet = workbook.getActiveSheet();

        for(var i = 0; i < providers.length; i++) {//each provider

        activeSheet.applyFilterAsync("Provider Name",providers[i],tableauSoftware.FilterUpdateType.REPLACE);

        document.getElementById("left").contentWindow.location.reload();

        doc.from_html(document.getElementById("left"));

        doc.save("test_"+i+".pdf");

        }

        }

        </script>

      </head>

      <body>

        <div id="right">

        <button id="myButton" onclick="createPdf()">Convert to PDF</button>

        </div>

        <div id="left">

        </div>

      </body>

      </html>

        • 1. Re: Error: tableauSoftware is undefined
          Russell Christopher

          Hey Keith -

           

          First, get rid of the <script> element which references the "old" API: (viz_v1.js). It is probably causing namespace collisions.

           

          Next, make sure that the tableau_v8.js file is not only on your server (you've done this) , but that your browser is able to successfully DL it. Use your browser's developer tools to watch the "Network". Note how the file in question came across with no problems (second row, status OK/200):

           

          Screen Shot 2014-06-13 at 2.58.18 PM.png

          1 of 1 people found this helpful
          • 2. Re: Error: tableauSoftware is undefined
            keith.thompson.0

            Thank you Russell. I tried this from my local machine and was able to load successfully (attached image).

            tableauServer.PNG

            However, when I tried from the same IP address as where Tableau Server is installed, I got an error (attached image).

            tableauServer2.PNG

            I think I need to host this webpage on the same server with Tableau Server in order for my particular application to work if I am not mistaken (something about crossing domains).

            • 3. Re: Error: tableauSoftware is undefined
              Russell Christopher

              You shouldn't have to do that.

               

              What version of IE are you using? You are running at least IE8, correct? And you are NOT in any sort of compatibility mode to make the browser "act" older? If so, this stuff will fail.

               

              Try Chrome / Firefox from that same machine and see what happens

              • 4. Re: Error: tableauSoftware is undefined
                keith.thompson.0

                I checked the machine Tableau Server is on (I am remotely logged in) and it is running IE 8. On my local machine where I was able to download the tableau_v8.js file successfully in my browser, I am using Chrome 35. Yet, it still gives the same error about Uncaught Reference Error: tableauServer is Undefined.

                • 5. Re: Error: tableauSoftware is undefined
                  Russell Christopher

                  This is driving me crazy!

                   

                  The web server that you're running this web page isn't using SSL, is it? If you have a page served by https attempting to grab a script elsewhere via http, it'll fail.

                  1 of 1 people found this helpful
                  • 6. Re: Error: tableauSoftware is undefined
                    keith.thompson.0

                    No, it's not using SSL. I did find part of my problem though. I needed to declare the variables globally.   I don't get that Uncaught Reference Error anymore. Unfortunately, I also don't get any content from the view ... but I guess that is a different problem.

                     

                    <html>

                    <head>

                      <link rel="stylesheet" type="text/css" href="style.css">

                      <script language="javascript" type="text\javascript" src="http://myServer/javascripts/api/tableau_v8.js"></script>

                      <script language="javascript" type="text\javascript" src="jspdf.js"></script>

                      <script>

                      var viz,doc,workbook,activeSheet,div,url,options;

                      var providers = ["prov1","prov2"];

                      var createPDF = function() {

                      div = document.getElementById("left");

                      url = "http://myServer/views/myView";

                      options = {

                      width: div.offsetWidth,

                      height: div.offsetHeight,

                      hideTabs: true,

                      hideToolbar: true,

                      onFirstInteractive: function () {

                      workbook = viz.getWorkbook();

                      activeSheet = workbook.getActiveSheet();

                      }

                      };

                      viz = new tableauSoftware.Viz(div, url, options);

                      //workbook = viz.getWorkbook();

                      //activeSheet = workbook.getActiveSheet();

                      //doc = new jsPDF("landscape","mm","letter");

                      //for(var i = 0; i < providers.length; i++) {//each provider

                      //activeSheet.applyFilterAsync("Provider Name",providers[i],tableauSoftware.FilterUpdateType.REPLACE);

                      //document.getElementById("left").contentWindow.location.reload();

                      //doc.from_html(document.getElementById("left"));

                      //doc.save("test_"+i+".pdf");

                      //}

                      }

                      </script>

                    </head>

                    <body>

                      <div id="right">

                      <button id="myButton" onclick="createPDF">Convert to PDF</button>

                      </div>

                      <div id="left">

                      </div>

                    </body>

                    </html>