1 Reply Latest reply on Oct 12, 2017 9:03 AM by Anand Vadul

    getFiltersAsync triggering error

    Nathan Melis

      I'm getting the following JavaScript error while using the getFiltersAsync function.

      We are using Tableau Desktop 8.1.7 (64-bit) and Tableau Server 8.1.7 (64-bit).

       

      Uncaught TypeError: Cannot read property 'toString' of undefined vqlweb.js:1308
      tab.ApiEventHandler.$Avqlweb.js:1308
      tab.ApiEventHandler.handleEventvqlweb.js:1308
      tab.Application.$12vqlweb.js:1308
      bmscorlib.js:1

       

      Code is the following:

       

      tableauViz.getWorkbook().getActiveSheet().getWorksheets().get("Sheet 1").getFiltersAsync().then(
           function(result){
                console.log(result)
           }
      );
      

       

       

      Can someone tell me if this is a bug in the Tableau JavaScript API and if so what to do to report this bug?

       

      Thanks.

        • 1. Re: getFiltersAsync triggering error
          Anand Vadul

          For others on the same journey - this happens if there are no filters added to the filter shelf

           

          If you do have filters added, here is code to loop through them.

          tableauViz.getWorkbook().getActiveSheet().getWorksheets().get("Sheet 1").getFiltersAsync().then(

                          function(filterList) {

                              for (let filter in filterList) {

                                  if (filterList.hasOwnProperty(filter) &&

                                      filterList[filter].getFieldName() === "The Field") {

                                       //Assuming this is a categorical filter with min and max

                                       var fieldValue = filterList[filter].getMin().value;           

                                      console.log("The Field:" + fieldValue);

                                  }

                              }

                          }

           

           

          Hope this helps!