1 Reply Latest reply on May 23, 2012 4:19 AM by Russell Christopher

    Tableau Javascript API:  interrogate the current filter values for embedded dashboards?

    David Nanson

      Hi

       

      We are embedding Tableau Dashboards in our own web-application:

       

      Is there a way to interrogate the current filter values for embedded dashboards in the similar way that you can set a filter value?

       

      For example in the below, the javascript code      viz.filter({product_id: ['1', '4']});      sets the filter product_id to the values 1 and 4.

       

      For our purposes it would be useful to be able to use similar javascript code to interrogate the dashboard and know what the current value of a filter is. In this example it would be good to know what the viewer of the dashboard had set the ProductId filter to.

       

      Put another way:             viz.filter({product_id: ['1', '4']}); allows us to set the value for product_id , What Javascript code can we use to check what the current value(s) are for product_id ?

       

       

      <html>

      <head></head>

      <body>

      <script type="text/javascript" src="http://localhost:8000/javascripts/api/viz_v1.js"></script>

      <object class="tableauViz" width="800" height="600" style="display:none;">

      <param name="host_url" value="http%3A%2F%2Flocalhost%3A8000%2F" />

      <param name="site_root" value="" />

      <param name="name" value="EdgeExample1&#47;SimpleEGDashboard" />

      <param name="tabs" value="yes" />

      <param name="toolbar" value="yes" />

      </object>

      <form>

      </form>

      <script type="text/javascript">

              function useVizAPI() {

                    var viz = window.tableau.vizs[0];

                    viz.hide();

                    viz.show();

                    //viz.refresh();

                    //viz.revert();

      viz.filter({product_id: ['1', '4']});

               }

               if (document.addEventListener) {

      window.addEventListener("load", useVizAPI, false);

               } else if (document.attachEvent) {

      window.attachEvent("onload", useVizAPI);

               }

      </script>

      </body>

      </html>

       

       

      Thanks


      David