1 Reply Latest reply on Mar 29, 2018 10:55 AM by Carisa Chang

    Change value of date parameter in Tableau server using java script

    TK kan

      Hi, I have a scenario where I want to change the value of the parameter to current system date -1. My dashboards are embedded into a web portal and users will be accessing through it.

      Below is the code that I am using, however it is not updating the 'Current date' parameter with the current system date -1.


      <script type='text/javascript' src='http://server01/javascripts/api/viz_v1.js'></script>

      <div class='tableauPlaceholder' style='width: 1600px; height: 1230px;'><object class='tableauViz' width='1600' height='1230' style='display:none;'><param name='host_url' value='http%3A%2F%2Fpriappi01%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='CurrDept-Treemap_0&#47;ActiveEx' /><param name='tabs' value='yes' /><param name='toolbar' value='yes' /><param name='showAppBanner' value='false' /><param name='filter' value='iframeSizedToWindow=true' /></object></div>


      $(function() {

          var vizDiv = document.getElementById('viz');

          var vizURL = "http://servername/dashboardname";

          var options = {

              onFirstInteractive: function() {

                  workbook = viz.getWorkbook();

                  workbook.changeParameterValueAsync('Current Date', new Date());

                  viz.refreshDataAsync(); //Refresh the data




      viz = new tableauSoftware.Viz(vizDiv, vizURL, options);




      This is how my current date parameter looks like:


      Can anyone pls let me know whats wrong in the code?