0

In Tableau Server I'm trying to find a way to select specific sheets from a workbook (for exporting to PDF) via script / browser dev console / tabcmd / URL / API. Here's a real / live example, which can be played around with: https://help.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api_sample_export_to_pdf.htm

Exporting specific sheets from Tableau Workbook to PDF

So far I tried, inter alia, various JavaScript commands to get the right element and trigger a "click", but so far to no avail... the underlying *.js files reveal a lot but so far I had no luck in getting the proper handle.

(I managed to give the impression that the sheets were selected, i.e., the checkboxes were shown and ticked via my JavaScript, but that didn't budge the actual selection, e.g. the "2 of 6" in the screenshot above.)


Related links:

nutty about natty
  • 1,267
  • 2
  • 10
  • 17

2 Answers2

0

One approach (there might be much better ones...), which works for here:

const bla = document.getElementsByClassName('thumbnail-wrapper_f1gupj42')
bla[1].click()

That toggles the checkbox on the "College" sheet above :-)

nutty about natty
  • 1,267
  • 2
  • 10
  • 17
  • So far inexplicably, in the real "Tableau Server", which looks pretty much identical, this click (and variations of it) do nothing... so for now I can only toggle the checkbox in this dummy page... – nutty about natty Jun 14 '22 at 21:07
  • Maybe the reason it doesn't work in the non-public Tableau is the `Content Security Policy of your site blocks the use of **eval** in JavaScript` from **vqlweb.js / script-src / report only**... ? as the public API in the link above does not feature / list that "Issue" in the console... – nutty about natty Jun 16 '22 at 07:41
0

A solution which worked (not only worked in the API but also in my use case) is recording a puppeteer script and using the keyboard only (e.g. Tab, Enter, etc) to select the individual pages; recording mouse clicks did not work that well, but who needs a mouse anyway?

nutty about natty
  • 1,267
  • 2
  • 10
  • 17
  • Keyboard "events" could also be handled in JavaScript directly and probably applied here too alternatively... e.g. https://stackoverflow.com/questions/18316395/javascript-for-handling-tab-key-press – nutty about natty Jun 23 '22 at 06:47