4 Replies Latest reply on Mar 3, 2019 2:26 AM by Tamir Gilany

    Event Listener Parameter Changed non-reponsive

    Sebastian Saint Arroman

      Hi,

       

      I have an extension that should refresh every time a filter or a parameter is changed. To refresh on filter changes, I've set an event listener on every worksheet and these work fine.

       

      I have tried to set an event listener for the parameter change onto the dashboard as below, but find that the extension does not refresh on a parameter change:

       

      function registerAllHandlers(settings) {

              // register FilterChange event handlers for all worksheets

              _unregisterHandlerFunctions = [];

              const worksheets = tableau.extensions.dashboardContent.dashboard.worksheets;

              // loop through all of these worksheets and add buttons for each one

              worksheets.forEach(function (worksheet) {

                 var unregisterHandlerFunction = worksheet.addEventListener(tableau.TableauEventType.FilterChanged, function(selectionEvent) {

                      refreshExtension();

                  });

                  _unregisterHandlerFunctions.push(unregisterHandlerFunction);

              });

              // Next, add parameter change listener to dashboard object

              const dashboard = tableau.extensions.dashboardContent.dashboard;

              var unregisterHandlerFunctionParam = dashboard.addEventListener(tableau.TableauEventType.ParameterChanged,function (selectionEvent) {

                refreshExtension();

              });

              _unregisterHandlerFunctions.push(unregisterHandlerFunctionParam);

          }

       

      I've also tried adding it to every worksheet instead of to the dashboard:

       

      function registerAllHandlers(settings) {

              // register FilterChange event handlers for all worksheets

              _unregisterHandlerFunctions = [];

              const worksheets = tableau.extensions.dashboardContent.dashboard.worksheets;

              // loop through all of these worksheets and add buttons for each one

              worksheets.forEach(function (worksheet) {

                  // add filter change listener

                 var unregisterHandlerFunction = worksheet.addEventListener(tableau.TableauEventType.FilterChanged, function(selectionEvent) {

                      refreshExtension();

                  });

                  _unregisterHandlerFunctions.push(unregisterHandlerFunction);

                  // add parameter change listener

                  var unregisterHandlerFunctionParam = worksheet.addEventListener(tableau.TableauEventType.ParameterChanged,function (selectionEvent) {

                      refreshExtension();

                  });

                  _unregisterHandlerFunctions.push(unregisterHandlerFunctionParam);

              });

          }

       

      When wrapping the parameter change event listener in a try, I catch the error that the documentation tells me should be thrown if addEventListener doesn't support the eventType parameter passed. However, the documentation for TableauEventType says that I've used an acceptable type. I've also tried using "parameter-changed" as a parameter to addEventListener to no avail.

       

       

      Thanks very much