2 Replies Latest reply on Aug 10, 2017 11:40 PM by padma k

    Special characters in webdataconnector

    padma k

      Hi All,

       

      I am trying to pull data from REST API using Webdataconnector and i have problem in getting data from columns with special characters in it like column name is km/hr or Mr.

       

      If i use table with normal column names i.e without any special characters in it then its working fine.As i am using nosql i.e cassandra it will column names with special characters in it.

       

      here is what i get in debug i.e when i press F12 in browser

       

      Version Bootstrap is not defined, Initializing SimulatorDispatcher

      tableauwdc-2.2.latest.js:509 Initializing message handling

      tableauwdc-2.2.latest.js:725 Initializing public interface

      tableauwdc-2.2.latest.js:771 Initializing private interface

      tableauwdc-2.2.latest.js:352 Initializing shared WDC

      tableauwdc-2.2.latest.js:374 SyntaxError: Unexpected token {

      Shared._errorHandler @ tableauwdc-2.2.latest.js:374

      readcs.js:62 Uncaught SyntaxError: Unexpected token {

      tableauwdc-2.2.latest.js:581 Uncaught Looks like the WDC is calling a tableau function before tableau.init() has been called.

      tableauwdc-2.2.latest.js:681 Received message!

      tableauwdc-2.2.latest.js:374 null

      Shared._errorHandler @ tableauwdc-2.2.latest.js:374

      tableauwdc-2.2.latest.js:685 Uncaught No WDC registered. Did you forget to call tableau.registerConnector?

      tableauwdc-2.2.latest.js:581 Uncaught Looks like the WDC is calling a tableau function before tableau.init() has been called.

       

       

      I tried this in simulator and when i click on getdatabutton then nothing is happening and it just stays there not returning to main browser if i have column with special characters in it.

       

      Here is my code jquery file

       

      (function() {

          // Create the connector object

          var myConnector = tableau.makeConnector();

       

          // Define the schema

          myConnector.getSchema = function(schemaCallback) {

              var emp_cols = [ {

                  id: "abc/def",

                  dataType: tableau.dataTypeEnum.string

              }];

       

              var opTable = {

                  id: "op",

      columns: emp_cols

              };

       

              var dept_cols = [ {

                  id: "W/T",

                  dataType: tableau.dataTypeEnum.int

              } {

                  id: "test.",

                  dataType: tableau.dataTypeEnum.int

              }];

       

              var cuTable = {

                  id: "cu",

      columns: dept_cols

              };

      schemaCallback([opTable,cuTable]);

          };

       

          // Download the data

          myConnector.getData = function(table, doneCallback) {

              $.getJSON("http://localhost:3000/op", function(resp) {

                  var feat = resp,

                      tableData = [];

       

      if (table.tableInfo.id == "op") {

                  // Iterate over the JSON object

                  for (var i = 0, len = feat.length; i < len; i++) {

                      tableData.push({

                        "abc/def":feat[i].abc/def,

                      

                      });

                  }

      }

       

                  table.appendRows(tableData);

                  doneCallback();

              });

      $.getJSON("http://localhost:3000/cu", function(resp) {

                  var feat = resp,

                      tableData = [];

       

       

        if (table.tableInfo.id == "cu") {

                  // Iterate over the JSON object

                  for (var i = 0, len = feat.length; i < len; i++) {

                      tableData.push({

                         "W/T": feat[i].W/T,

      "Test.": feat[i].Test.,

                          });

                  }

      }

                  table.appendRows(tableData);

                  doneCallback();

              });

          };

       

          tableau.registerConnector(myConnector);

       

          // Create event listeners for when the user submits the form

          $(document).ready(function() {

              $("#submitButton").click(function() {

                  tableau.connectionName = "Employee Details"; // This will be the data source name in Tableau

                  tableau.submit(); // This sends the connector object to Tableau

              });

          });

      })();

      (function() {
          // Create the connector object
          var myConnector = tableau.makeConnector();
          // Define the schema
          myConnector.getSchema = function(schemaCallback) {
              var emp_cols = [{
                  id: "emp_id",
                  dataType: tableau.dataTypeEnum.int
              }, {
                  id: "emp_city",
                  dataType: tableau.dataTypeEnum.string
              }, {
                  id: "emp_name",
                  dataType: tableau.dataTypeEnum.string
              }, {
                  id: "emp_phone",
                  dataType: tableau.dataTypeEnum.float
              }, {
                  id: "emp_sal",
                  dataType: tableau.dataTypeEnum.float
              }, {
                  id: "dept_id",
                  dataType: tableau.dataTypeEnum.int
              }];
              var empTable = {
                  id: "emp",
      columns: emp_cols
              };
              var dept_cols = [{
                  id: "dept_id",
                  dataType: tableau.dataTypeEnum.int
              }, {
                  id: "dept_name",
                  dataType: tableau.dataTypeEnum.string
              }];
              var deptTable = {
                  id: "dept",
      columns: dept_cols
              };
      schemaCallback([empTable,deptTable]);
          };
          // Download the data
          myConnector.getData = function(table, doneCallback) {
              $.getJSON("http://localhost:3000/emp", function(resp) {
                  var feat = resp,
                      tableData = [];
      if (table.tableInfo.id == "emp") {
                  // Iterate over the JSON object
                  for (var i = 0, len = feat.length; i < len; i++) {
                      tableData.push({
                          "emp_id": feat[i].emp_id,
                          "emp_city": feat[i].emp_city,
                          "emp_name": feat[i].emp_name,
      "emp_phone":feat[i].emp_phone,
                          "emp_sal":feat[i].emp_sal,
      "dept_id":feat[i].dept_id,
                      });
                  }
      }
                  table.appendRows(tableData);
                  doneCallback();
              });
      $.getJSON("http://localhost:3000/dept", function(resp) {
                  var feat = resp,
                      tableData = [];
        if (table.tableInfo.id == "dept") {
                  // Iterate over the JSON object
                  for (var i = 0, len = feat.length; i < len; i++) {
                      tableData.push({
                          "dept_id": feat[i].dept_id,
                          "dept_name": feat[i].dept_name,
                          });
                  }
      }
                  table.appendRows(tableData);
                  doneCallback();
              });
          };
          tableau.registerConnector(myConnector);
          // Create event listeners for when the user submits the form
          $(document).ready(function() {
              $("#submitButton").click(function() {
                  tableau.connectionName = "Employee Details"; // This will be the data source name in Tableau
                  tableau.submit(); // This sends the connector object to Tableau
              });
          });
      })();if