13 Replies Latest reply on May 19, 2020 2:47 PM by Bahjat Kseibi

    JavaScript API EventListner Filter Values

    Bahjat Kseibi



      I am trying to store selected filter values from a dashboard which contains multiple sheets all sheets are utilizing the same data source and all filters apply across the entire data source:



      I tried following this method:


      let viz, workbook, activeSheet


      //function called by viz on filter value change in dashboard


      function onFilterSelection(filterEvent) {

         return filterEvent.getFilterAsync().then(reportSelectedFilter);


      function reportSelectedFilter(filter) {

         // If I uncomment the below alert the alert will loop for about three to 4 times...

         //alert("Capturing filter values");//+ filter.$9[0].value());
        // let pairs = filter.filterValue();
        // let pairs =filter.$9[0].value();
        //let value = filter.getAppliedValues();
        // If I am using the developer tool in a browser, pairs shows up as undefined but if I hover over "filter.$9" then I see the filter selected values

        let pairs =filter.$9;





      // Initialise the viz to hold the workbook
      function initViz(){

         var placeholderDiv = document.getElementById("tableauViz");
        var url = \\MyDashboardURL;
        var options = {


         onFirstInteractive: function () {

        workbook = viz.getWorkbook();
         activeSheet = workbook.getActiveSheet();

         viz = new tableau.Viz(placeholderDiv, url, options);
         // Add event listener
         viz.addEventListener(tableau.TableauEventName.FILTER_CHANGE, onFilterSelection);


      Can someone help please!