1 Reply Latest reply on May 4, 2018 12:42 AM by Ciaran Bource

    Applying filters to select worksheets within a dashboard through javascript api and getting 500 error from server?

    Lucy Ji

      I'm using the javascript API to load a tabbed workbook where each tab is a dashboard, and each dashboard contains multiple worksheets. In the original workbook, certain worksheets have a relative date filter applied to them while others do not. In my javascript that embeds the workbook, I'd like to apply different relative date filters to the sheets that the date filter was originally applied, ignoring the sheets that don't have the date filter applied.


      The code below is along the lines of how I create the viz and apply the filter. When a new date filter option is selected (code not shown), I call filterVizStartDate below with the new filter options, which iterates through each worksheet within the dashboard, gets the filters on the worksheet, checks whether the worksheet has the date filter, and then applies the date filter with the new options if the sheet has the date filter enabled.



      var vizActiveWorksheets;
      var options = {
           hideTabs: true,
           hideToolbar: true,
           onFirstInteractive: () => {
                vizActiveWorksheets = viz.getWorkbook().getActiveSheet().getWorksheets();
      var viz = new tableau.Viz(placeholderDiv, url, options);
      var filterVizStartDate = (options) => {
           vizActiveWorksheets.forEach(worksheet =>
                     .then(filters => {
                          if (filters.get('Start Date')) {



      The filterVizStartDate code works the first time that it's called (as in the date filter is applied successfully to select sheets within the dashboard), but on subsequent calls I get a 500 POST exception rom the javascript api that seems to be happening in getFiltersAsync. The stack trace from the error message looks like this:


      "Error at new Exception$ (http://localhost:3000/tableau-2.2.1.min.js:4:30273) at Function.q.create (http://localhost:3000/tableau-2.2.1.min.js:8:5728) at Function.q.createServerError (http://localhost:3000/tableau-2.2.1.min.js:8:6326) at http://localhost:3000/tableau-2.2.1.min.js:10:49615 at O.$2 (http://localhost:3000/tableau-2.2.1.min.js:8:37958) at O.$1 (http://localhost:3000/tableau-2.2.1.min.js:8:36980) at delegate (http://localhost:3000/tableau-2.2.1.min.js:4:17752)"


      The message in the exception is simply '[Object object]' and does not give me any info. When I look at the network console in Chrome, the request that failed was named 'get-filter-info' with the following http response from tableau:


      TableauException: Incorrect data type.


      Any idea on what is causing this? Is there perhaps a different way of selectively applying filters to sheets within a dashboard that I should be doing instead?