7 Replies Latest reply on Apr 21, 2014 5:58 PM by Russell Christopher

    Filter on GET request Tableau API v8.js

    Charles Taylor

      I am receiving a odd error from this script in IE8

      Full script here: [JavaScript] trouble - Pastebin.com

       

      But I believe the issue is coming from here:

       

       

        function initializeViz(batchID) {

             var placeholderDiv = document.getElementById("Target");

             var url = "HIDDEN";

                  var options = {

                  width: 800,

                  height: 750,

                  hideTabs: true,

                  hideToolbar: true,

                  onFirstInteractive: function () {

                       workbook = viz.getWorkbook();

                       activeSheet = workbook.getActiveSheet();

                       setTimeout(

                            function() {

                                 filterTableauVizByBatchId(batchID);

                           }, 10000);

                       window.setInterval("refresh()",10000);

                       }

        };

       

      The error I receive is

      SCRIPT5007: Unable to get property 'get__workbook' of undefined or null reference

      tableau_v8.js, line 192 character 2156

       

      Also it will only sometimes filter on the batch id I was wondering does anyone have a solution to having the Viz filter dynamically based on a GET request?

        • 1. Re: Filter on GET request Tableau API v8.js
          Russell Christopher

          Hey Charles -

           

          Quick question - you specifically mention IE8 - Are you saying that it works in IE9, Chrome, FireFox? If you haven't tested, could you?

           

          Have you actually stepped through this code to see exactly where it fails?

          1 of 1 people found this helpful
          • 2. Re: Filter on GET request Tableau API v8.js
            Charles Taylor

            So this is a corporate computer I actually don't have FF, however, I do have chrome and I can test in all versions of IE and it works in Chrome and IE 9 - 11.

             

            I understand it is hard to diagnose the issue without seeing the Viz, however, if you have any input on that error or what it could be referring to

             

            As I step through the code it encounters the error at this point, then goes into the API and gives me the error.

             

             

            <html>

            <Title></Title>

            <Head>

              <meta http-equiv="X-UA-Compatible" content="IE=edge"/>

             

             

              <script type="text/javascript" src="js/tableau_v8.js"></script>

              <script type="text/javascript" src="js/main_functions.js"></script>

            </Head>

            <div  id="Target" style="position: relative; width: 800; height: 400" ></div>

            <body onload="initializeViz(parseGet())">

              <div>

              <form>

              <input type="button" value="refresh" onclick="refresh()">

              </form>

              </div>

            </body>

             

             

            </html>

            • 3. Re: Filter on GET request Tableau API v8.js
              Russell Christopher

              Assuming IE8 has a decent set of F12 Devtools,  you should be able to put a breakpoint directly in your JS and hit each line to see where it fails….either that, or comment out all the stuff in OnFirstInteractive and see if it renders properly in a very vanilla way.

               

              I’d try this myself, but I don’t have IE8.

               

              Also, make sure you have the <!DOCTYPE html> declaration at the top of your page. I’ve seen things act weird in IE when this is missing.

              1 of 1 people found this helpful
              • 4. Re: Filter on GET request Tableau API v8.js
                Charles Taylor

                It appears plain vanilla does not spit this error out, I will try a few other solutions, and report back thank you for your guidance.

                • 5. Re: Filter on GET request Tableau API v8.js
                  Russell Christopher

                  One thing you can do is filter before the viz is rendered. Much better user experience, anyway and might make your problem go away:

                   

                  var mainVizDiv = $("#mainViz");
                      var mainWorkbookUrl = "http://" + serverName + "/t/SkunkWorks/views/JavaScriptTarget/Dashboard";
                      var mainVizOptions = {
                          hideTabs: false,
                          hideToolbar: false,
                          width: mainVizDiv.parent().innerWidth() + "px",
                          height: mainVizDiv.parent().innerHeight() + "px",
                          //Filter Category field - note NO spaces between multiple filter values. Just a comma
                          Category: "Office Supplies,Furniture",
                          //Set Top Customers Parameter Value - note wrapping quotes around parameter name since it contains spaces
                          "Top Customers": 22,
                          onFirstInteractive: function () {
                              mainWorkbook = mainViz.getWorkbook();
                          }
                      };
                      //  Create viz
                      mainViz = new tableauSoftware.Viz(mainVizDiv[0], mainWorkbookUrl, mainVizOptions);
                  }
                  
                  
                  1 of 1 people found this helpful
                  • 6. Re: Filter on GET request Tableau API v8.js
                    Charles Taylor

                    This seems to be a really fast way of filtering (thanks for that! ); however, it doesn't seem to change the error appearing

                     

                    function initializeViz(batchID) {
                           var placeholderDiv = document.getElementById("Target");
                           var url = "SERVERNAME";
                           var options = {
                                width: 800,
                                height: 400,
                                hideTabs: true,
                                hideToolbar: true,
                                Category: "I_BATCH_ID",
                                "I_BATCH_ID": batchID,
                                onFirstInteractive: function () {
                                     workbook = viz.getWorkbook();
                                     activeSheet = workbook.getActiveSheet();
                    
                              
                    
                                }
                    };
                    
                    

                     

                    I still receive the error below:

                     

                    SCRIPT5007: Unable to get property 'get__workbook' of undefined or null reference

                    tableau_v8.js, line 192 character 2156

                     

                    Again ONLY in IE8.

                    • 7. Re: Filter on GET request Tableau API v8.js
                      Russell Christopher

                      By chance are you running IE8 in some sort of compatibility mode? That won’t work.