1 Reply Latest reply on Jun 26, 2015 3:02 PM by Patrick A Van Der Hyde

    JavaScript filter param not working

    Balakumar Seethapathy

      Hi All,

       

      I have a "Measure" database column as filter in my tableau view. When I pass the value in Javascript initialize viz call its not loading the view with filtered param applied. I have given my code here(hiding sensitive information), please let me know what's the issue with the code.

       

      <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">

      <html>

      <head>

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

      <script type="text/javascript" src="tableau-2.0.0.min.js"></script>

      <style>

      #header {

         line-height:30000px;

         background-color:#eeeeee;

         height:3000px;

         width:1000px;

         float:left;

         padding:5px;

      }

      </style>

      <script type="text/javascript">

      // Global variables

      var viz, workbook, activeSheet, trustedTicket;

      function getTrustedTicket() {

      var requestData = {

      username:"tcatableau",

      server:"http://<server>/trusted"

      };

      $.ajax({url: "<url>", data: { method: "TableauTrustedTicket", userName: "<username>", server: "http://<server>/trusted"}, success: function(data) {

        console.log("Ticket: " + data.ticket);

        trustedTicket = data.ticket;

        draw();

      }, dataType: "json"}).error(function() { alert('Trusted Ticket call failed');

      });

      }

      function initializeViz() { 

        getTrustedTicket();   

      }

      function draw() {

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

        var url = "http://<server>/trusted/" + trustedTicket + "/views/Book3/Sheet1#2:<Filter-FieldId>=209140";

        var options = {

          width: placeholderDiv.offsetWidth,

          height: placeholderDiv.offsetHeight,

          hideTabs: true,

          hideToolbar: true,

        //<Filter-FieldId>: 209140,

          onFirstInteractive: function () {

            workbook = viz.getWorkbook();

            activeSheet = workbook.getActiveSheet();

         //filterSingleValue();

          }

        };

        viz = new tableau.Viz(placeholderDiv, url, options);

      }

      $(document).ready(function(){

          alert("123abc");

          initializeViz(); 

        //alert("after initialization!! now apply filter!!");

      });

      </script>

      </head>

      <body>

      <div id="tableauViz" style="height:600px; width:1200px;">

      </div>

      </body>

      </html>

       

       

      I have tried passing the filter param in option/url and in Filter Async methods but its not working. Please help me.

       

      Thanks,

      Balakumar