2 Replies Latest reply on Feb 25, 2014 2:35 PM by Tony Kau

    Workbooks on Tableau Server Randomly Reverting after Idle

    Tony Kau

      Hi all,

       

      This issue has existed for as long as I've been publishing on our Tableau Server, but I finally have a JavaScript navigation wrapper set up, and it's causing confusion.

       

      This issue happens when I publish a workbook to our server, then go use it as one normally would (changing filters/tabs/parameters/etc.), then I leave it alone for a couple minutes, sometimes hours (and sometimes it doesn't happen at all).  When I switch to the browser window to use the viz again, sometimes it will revert to the original saved state without any interaction on my part, other than bringing the window in focus, perhaps.

       

      The problem is that the parameters and tab selection are done by the javascript wrapper and are still set to the last place I left it before the embedded viz reverted.  So, if I've drilled down to view, say, North America, the viz would revert to the default saved state (Global), but the javascript wrapper dropdown would still show North America. 

       

      If I could disable this automatic, random reversion, that would be ideal.

       

      If I could know which "event" was firing, I could hook into it and run a changeParameter function to set each according to the state of the wrapper, so, that could be a potential workaround.

       

      Has anyone experienced this, and if so, how have you dealt with it?

        • 1. Re: Workbooks on Tableau Server Randomly Reverting after Idle
          Tony Kau

          More clues:

          I think it may be due to the Tableau Server cache expiring.  When it reverts just by setting the focus to viz, I get this error message in the Chrome console.  Any idea how to tap into that revert event to then apply parameters?

           

          Thank you!

          Capture.PNG.png

          • 2. Re: Workbooks on Tableau Server Randomly Reverting after Idle
            Tony Kau

            Workaround achieved!

             

            I haven't been able to hook into that random cache expiration/revert/refresh/reload event, but I was able to work around it by disposing of and reloading the viz when I change parameters/sheets instead of using

             

            workbook.changeParameterValueAsync(paramName,paramValue);
            

             

            Here's what I did:

             

            1. Declare viz variables and parameters outside the load function so they persist outside of the initial window.onload() function.
            2. Load the viz like normal
            3. When you want to change a parameter/sheet just change it's variable, e.g. paramDate = '2014-02-25'
            4. Use a function to overwrite the vizURL variable with the latest parameters
            5. Use a function to dispose of the existing viz and re-instantiate with the new URL (with the new parameters embedded).

             

            It doesn't look like the code embedding is working well for me, so hopefully this works:

             

             

             

            <script>
            // Step 1: Declare viz variables
            var viz;
            var loadSheet = 'Overview';
            var paramReportDate = Date.parse("last saturday").toString("yyyy-MM-dd");
            var paramRegion = 'Global';
            var paramType = 'All';
            var vizDiv;
            var vizURL;
            var options;
             
             
            // Step 2: Load viz like normal
            window.onload=function() {
              vizDiv = document.getElementById('viz');
              vizURL = "http://tableau-server/views/path-to-dash/".concat(loadSheet).concat("?:linktarget=_self&:embed=y&:tabs=n&:toolbar=n&ReportRegion=").concat(paramRegion).concat("&ReportType=").concat(paramType).concat("&ReportDate=").concat(paramReportDate);
              options = {
               width: '1200px',
               height: '800px',
               customViews: 'no',
               hideTabs: true,
               hideToolbar: true
               };
              viz = new tableauSoftware.Viz(vizDiv, vizURL, options);
              
              viz.addEventListener('marksselection', marksSelected);
             
            };
             
            // Step 3: On the action when you want to change a sheet or parameter, change the javascript variable
            // Change region in dropdown
              $(document).ready(function(){
               $("ul#region-dropdown-ul li a").click(function(){
                
                // assign the new value to our variable
                paramRegion = this.id;
                
                // call 'loadViz()' which is our action function
                loadViz();
                
               });
              }); 
              
             
            // Step 4: concatenate all of our parameters into a new URL string:
            function updateVizURL() {
              vizURL = "http://tableau-server/views/path-to-dash/".concat(loadSheet).concat("?:linktarget=_self&:embed=y&:tabs=n&:toolbar=n&ReportRegion=").concat(paramRegion).concat("&ReportType=").concat(paramType).concat("&ReportDate=").concat(paramReportDate);
            }  
              
              
            // Step 5: use loadviz() to call the updateVizURL() function and reload the new URL
            function loadViz() {
                 if (viz !== null) {
               // get rid of the existing viz, if it exists
               viz.dispose();
              }
              
              // pull the updated parameter into our URL (code in step 4)
              updateVizURL();
              
              // load the new viz (in the same spot, with the new URL, with the same options)
              viz = new tableauSoftware.Viz(vizDiv, vizURL, options);
              
              // re-add any event listeners you had
              viz.addEventListener('marksselection', marksSelected);
            }
            </script>