1 Reply Latest reply on Jun 28, 2016 11:42 AM by Aaron Clancy

    Javascript API get all marks on a specific worksheet of a dashboard

    Aaron Clancy

      Hi All,

      Im trying to do the following:

       

      Load a viz with the Javascript API.

      Then, with click actions from one sheet, filter another sheet on the same dashboard.

      After I've clicked my desired items, I would like to have an HTML button that "grabs" all the visible mark details for the second sheet to be used elsewhere.

       

      Here is the current approach I am using:

      First I create an index on my marks in the view.

       

      Here is the function I am using to select the first N number of marks from the final sheet after the click actions have been applied.

       

      function highlightAll(){

        viz.getWorkbook().activateSheetAsync(0);

        var view = viz.getWorkbook().getActiveSheet().getWorksheets();

        worksheet = view[3];

        items = [];

        for (N=1;N<100;N++){

        items.push(N);     

           };

           worksheet.selectMarksAsync({"AGG(index)":items},tableau.SelectionUpdateType.ADD);  

      };

       

      In the above example, my thought was to assign an index in the sheet to each mark, then iterate through all values with selectMarksAsync()  (assuming I wanted first 100 etc...)

      Then I could use the marks_selection event listener, but this is messy.

       

      Is there a way to do this without having to select all the marks first before being able to access the values?

       

      Any help as greatly appreciated

        • 1. Re: Javascript API get all marks on a specific worksheet of a dashboard
          Aaron Clancy

          I figured out the index loop made no sense so I replaced it with a static calculated field called "all"  with a value of "all."

           

          The code is now more concise and accounts for any N number of values:

           

          function test(){

            var view = viz.getWorkbook().getActiveSheet().getWorksheets();

            worksheet = view[3];

            worksheet.selectMarksAsync("all","all",tableau.SelectionUpdateType.ADD);

          };

           

           

          But I would still like to know if there's a way to do this without having to select the marks.