1 Reply Latest reply on Jul 16, 2016 6:06 AM by Tamas Foldi

    JS API Issues

    Jason Rendel

      Hello:

       

      I'm struggling to use some of the JS API samples provided.  There seems to be a disconnect with the Sheet vs Worksheet objects. 

       

      viz.getWorkbook().getActiveSheet() returns a sheet...

      viz.getWorkbook().activateSheetAsync() returns a promise that returns a sheet...

       

       

      selectMarksAsync() or applyFilterAsync() among many others from the samples aren't available on a Sheet object.

       

      Instead you need to jump through unexpected and undocumented hoops to get a Worksheet object

       

        _viz.addEventListener(tableau.TableauEventName.TAB_SWITCH, function(e){

            console.log("TAB_SWITCH");

            if(e.getNewSheetName() != "Performance")

            {

              var newSheetName = e.getNewSheetName();

             

              console.log("Not performance..." + newSheetName);

              console.log("...let's try to set the optional field picker.");

             

              _sheet = _viz.getWorkbook().getActiveSheet().getWorksheets().find(function(s){return s.Name = newSheetName;});       

             

              _sheet.applyFilterAsync("Optional Field Name", "Division", tableau.FilterUpdateType.REPLACE);       

            }

         

        });

       

      That's just crazy....

       

      Then I attempt the call to applyFilterAsync() and I get a 500 server error.

       

      Using the JS API is pretty frustrating so far I'm finding.    I tried the support team but they just encouraged me to post this out here.

       

      Has anyone had any luck with the calls to applyFilterAsync()?