1 Reply Latest reply on Sep 5, 2018 8:18 AM by Raleigh Chen

    Calling getFiltersAsync() on a sheet that has an OLAP source throws an uncatchable exception

    Raleigh Chen

      I have a Tableau workbook with a source that is a cube.  Part of my standard logic for embedding involves getting the list of filters on the sheets in the embedded workbook.  For that purpose, I call getFiltersAsync().  When I run my standard logic against this workbook, it throws the following exception:

       

      Exception$ {_message: "Duplicate key 'Generations_hierarchical'", _innerException: null, _error: Error

          at new Exception$ (https://public.tableau.com/javascripts/api/tableau-2.2.2.js:1522:17)

       

      I've tried wrapping it in a try catch block, and I've tried chaining the call with an "otherwise" block, but nothing seems to be working.  Has anyone encountered this before?  Any idea on how to work around this so at least my script will continue running instead of just getting killed off?  At this point, I have stuff I try to run in the "then" block, but I can't ever get inside that block when the source is the OLAP workbook.

       

      Here's my script so far:

       

      var viz, workbook, activeSheet, activeSheetsInDashboard;

        

      function initViz() {

           var containerDiv = document.getElementById("vizContainer"),

           url = "http://prodtabprim1w:8000/t/8/views/EssbaseTest/Level0Dashboard",

           options = {

                hideTabs: true,

                onFirstInteractive: function () {

                     workbook = viz.getWorkbook();

                     activeSheet = workbook.getActiveSheet();

       

                     activeSheetsInDashboard = [];

                     // Populate the dashboardMeta object for quicker use in later functions

                     if (activeSheet.getSheetType() === tableau.SheetType.DASHBOARD) {

                          activeSheetsInDashboard = activeSheet.getWorksheets();

                     } else {

                          activeSheetsInDashboard.push(activeSheet);

                     }

       

                     activeSheetsInDashboard[0].getFiltersAsync()

                          .then(function(arrayOfFilters) {

                               alert(arrayOfFilters.length);

                          })

                          .otherwise(function(err) {

                               console.log("Failed to retrieve Filters for Tableau Viz.  May be due to OLAP source.");

                          });

                }

           };

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

      }

        • 1. Re: Calling getFiltersAsync() on a sheet that has an OLAP source throws an uncatchable exception
          Raleigh Chen

          For technical types, I'm finding that the specific issue is that when I'm running the getFilterAsync command, it kicks off the Promise process, but that separate process throws an exception that isn't caught by Tableau's native otherwise function.  The exception is being thrown by the $verifyUniqueKeyParameter: function DoNotUseCollection$verifyUniqueKeyParameter (which I'm not sure exactly what it is....).

           

          But regardless, based on my understanding of Promises, if an exception is thrown in the Promise, it should be caught by the "catch" block (which I am assuming is equivalent to Tableau's otherwise block).  Anyone have experience with otherwise actually working?