1 Reply Latest reply on Oct 12, 2018 1:01 AM by Man Tsui

    How to get the filters of the linked data after apply filter

    Kevin Xu

      Hi,  I want to apply filter by JavaScript API, and get the filters return the data after the change, but now I find that the value I got after applying the filter cannot be correlated.  when I apply the filter, the get filter only changed the current content. I want to achieve the linkage between multiple filters.

       

      Thanks!

        • 1. Re: How to get the filters of the linked data after apply filter
          Man Tsui

          Hi Kevin,

           

          Try wrapping the getFilterAsync() or getData() inside the applyFilterAsync using "then" promise

           

          // Filter the specified dimension to the specified value(s)

          function setFilterTo(vizName, sheetName, filterName, values) {

               var sheet = vizName.getWorkbook().getActiveSheet().getWorksheets().get(sheetName);

              sheet.applyFilterAsync(filterName, values, tableau.FilterUpdateType.REPLACE).then( function(field){

                    getFilterAsync();

               });

          }

           

          Promise Class

          Represents a promise to return a value from an asynchronous method in the future. The Tableau JavaScript API implements the Promises/A specification.

          Methods

          Name

          Return Type

          Description

          then(callback: Function, errback: Function)

          Promise

          Creates a link in the asynchronous callable chain. The callback function is called on success. The errbackfunction is called when there is an error. Both parameters are optional.

           

          https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then