I hope it is helpful, Gigi", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D5KX00000kQw4p0AC", "datePublished": "2019-07-16T23:06:29.000Z", "author": { "@type": "Person", "name": "Geraldine Zanolli", "url": "https://trailblazers.salesforce.com/profileView?u=0054V00000HOFxXQAX", "affiliation": { "@type": "Organization", "name": "--" } } }, "suggestedAnswer": [] } } Skip to main content

Hello All,

 

I am new to integrating and using Tableau Javascript API. I am trying to implement a behaviour where user should be able to save the filters applied on a dashboard (containing many sheets).

 

I understand we can get the applied filters using `getAppliedValues` function but I am not sure how should i go about saving the values from `getAppliedValues` function as it seems to return a lot of data.

 

And, how can i use the response returned by `getAppliedValues` and later use to preload the dashboard to load with filters already set.

 

In case anyone can point me in the correct direction or share some sample code in case they have implemented something similar it would be very helpful, Thanks.

4 respostas
  1. 16 de jul. de 2019, 23:06

    Hi Akshar,

     

    I did some testing on my side.

     

    You would need to call first the function getCustomViewAsync and then showCustomViewsAsync(). Custom views are not guaranteed to be loaded when the viz becomes interactive. Using the function getCustomViewsAsync() makes sure that all the views are loaded before you call the showCustomViewsAsync method.

     

    For example:

    <body onload="initViz();">

        <div id="viz1"></div>

        <div id="viz2"></div>

        <script type="text/javascript">

            function initViz() {

                var url1 = "https://dub01.online.tableau.com/t/geraldinessite/views/testgigi/SalesDashboard";

                var vizDiv1 = document.getElementById('viz1');

     

                var options1 = {hideTabs: true, width: "1000px", height: "1000px",onFirstInteractive: function () {

                    workbook = viz.getWorkbook();

                    workbook.getCustomViewsAsync().then(function(){

                        workbook.showCustomViewAsync("test");

                        });

                }};

               

                viz = new tableau.Viz(vizDiv1, url1, options1);

               

            }

        </script>

    </body>

     

    I hope it is helpful,

    Gigi

0/9000