opensource-developer
opensource-developer

Reputation: 3068

url encoding issue - tableau js api

I am trying to load tableau dashboard with filter options already passed in, the javascript api correctly encodes string but when I have , in my values the encoding does not work as expected and dashboard does not load with applied filter.

here is a comparison of both the code

1) This works and load the dashboard with filter Operator set to Yuson Creek and url tableau api generates is https://myurl&Operator=Yuson%20Creek&:apiID=host0#navType=1&navSrc=Parse

tableauViz = new tableau.Viz(frameDiv[0], url, {
  highdpi: true,
  hideTabs: true,
  hideToolbar: true,
  width: "100%",
  height: "100%",
  "Operator": ["Yuson Creek"]
}); 

2) This code does not work, with filter value set to "Abc, M.L. Corp." and generates url https://myurl&Operator=Abc%2C%20M.L.%20Corp.&:apiID=host0#navType=1&navSrc=Parse

tableauViz = new tableau.Viz(frameDiv[0], url, {
  highdpi: true,
  hideTabs: true,
  hideToolbar: true,
  width: "100%",
  height: "100%",
  "Operator": ["Abc, M.L. Corp."]
}); 

Looks like when the filter value has a comma inside of the string the url encoding does not work as expected. I have also tried passing the strings like 'Abc%2C+M.L.+Corp.' but still it does not work.

How do i pass the string value when it has a comma inside of it.

Any help on this would be much appreciated. Thanks.

Upvotes: 0

Views: 310

Answers (1)

Timothy Henke
Timothy Henke

Reputation: 11

Yesterday I had this same issue using the Tableau API to retrieve an image for a view. This was solved by adding an encoded escape character in front of the comma. So a comma becomes %5C%2C after encoding.

Upvotes: 1

Related Questions