3 Replies Latest reply on Sep 20, 2018 9:15 AM by Jackie Gleason

    Tableau Connection Data working in Simulator but not in Tableau Desktop

    Jackie Gleason

      I have a Web Connector that uses connection data to store information about configuration options like this example. This works great when I try it out in the Simulator, I see the data based on the selection I made. However, when I try to use it with Desktop, I always get the default resultset. So it appears as though the connectionData is being ignored by desktop.

       

      1.) Can someone confirm this is the case?

      2.) If I can't use connectionData, what should I use to pass config options?

       

      If you need an example the following can be saved as an HTML. You can select the second item in the simulator and the result is name2. When you try the same thing in tableau desktop I get...

       

      tb2.PNG

       

       

      tb.PNG

       

      I would expect for the desktop one to be the same as above. My Tableau version is 10.3.4

       

       

      <html>

      <head>

         <meta http-equiv="Cache-Control" content="no-store" />

         <!--<script-->
        <!--src="https://code.jquery.com/jquery-3.3.1.slim.min.js"-->
        <!--integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E="-->
        <!--crossorigin="anonymous"></script>-->
         <script src="https://connectors.tableau.com/libs/tableauwdc-2.3.latest.js" type="text/javascript"></script>

         <script>

        (function(){

         var tableau = window.tableau;

         var myConnector = tableau.makeConnector();

         var choices = [

        {

         name: "1",

         value: {

         projectNames: "name1",

         startStatusId: "1",

         endStatusIds: "2",

        }

        },

        {

         name: "2",

         value: {

         projectNames: "name2",

         startStatusId: "3",

         endStatusIds: "4",

        }

        },

        {

         name: "3",

         value: {

         projectNames: "name3",

         startStatusId: "5",

         endStatusIds: "6",

        }

        }

        ];

         tableau.connectionData = JSON.stringify(choices[0]);

         myConnector.getSchema = function (schemaCallback) {

         var cols = [

        {

         id: "project",

         dataType: tableau.dataTypeEnum.string
         },

        {

         id: "start",

         dataType: tableau.dataTypeEnum.string
         },

        {

         id: "completed",

         dataType: tableau.dataTypeEnum.string
         }

        ];

         var tableSchema = {

         id: "kanbanFeed",

         alias: "Kanban project data over the last 30 days",

         columns: cols
         };

       

        schemaCallback([tableSchema]);

        };

       

         myConnector.getData = function (table, doneCallback) {

         var obj = JSON.parse(tableau.connectionData);

         if(obj.useFlag) path += "?flagged=true";

        table.appendRows([

        {

         project: obj.value.projectNames,

         start: obj.value.startStatusId,

         completed: obj.value.endStatusIds
         }

        ]);

        doneCallback();

        };

       

         window.changeTeam = function(){

         console.log("Ok we are in here");

         tableau.connectionData = JSON.stringify(choices[document.getElementById("team").selectedIndex]);

        };

       

       

         document.onreadystatechange = function () {

         if (document.readyState === "complete") {

         // document is ready. Do your stuff here
         document.getElementById("submitButton").addEventListener("click", function(){

         tableau.connectionName = "Kanban Data Feed";

         tableau.submit();

        });

         const select = document.getElementById("team");

         for(var i = 0; i < choices.length; i++){

         const choice = choices[i];

         select.options[select.options.length] = new Option(choice.name, JSON.stringify(choice.value));

        }

        }

        };

       

         tableau.registerConnector(myConnector);

        })()

         </script>

      </head>

      <body>

         <select id="team" onchange="window.changeTeam();"></select>

         <button type="button" id="submitButton" class="btn btn-success" style="margin: 10px;">Select Team</button>

      </body>

      </html>