6 Replies Latest reply on Mar 9, 2015 4:53 PM by Robert Crocker

    Does anyone know how to return the object containing all Custom Views that have been remembered?

    Robert Crocker

      I'm trying to create a custom application the provides the user with similar functionality as those with access to native Tableau Server.  The feature I'm currently working on is the Remember feature allowing users to essentially save favorites.

       

      The JavaScript API's viz.getWorkbook().rememberCustomViews("view name") does allow users to save their favorites.  How do you get the list of saved view returned?

       

      When I run viz.getWorkbook().getCustomViewsAsync() I see that an object is returned, but I'm struggling to make sense of the object.

        • 1. Re: Does anyone know how to return the object containing all Custom Views that have been remembered?
          Russell Christopher

          Heya Robert -

           

          Using the method above will return an array of CustomView objects.

           

          You could then walk this array and call methods like .getName() to see the name of the CustomView, or maybe getWorkbook() to get back the workbook on which the CustomView itself is originally based.

           

          It sounds like you have the "creation part" figured out, what part are you missing? I'm not 100% clear on that based on what you wrote above.

           

          Cheers!

          1 of 1 people found this helpful
          • 2. Re: Does anyone know how to return the object containing all Custom Views that have been remembered?
            Robert Crocker

            I've been thinking about this over the week and I probably confused you and others because I didn't fully understand what I was asking.

             

            Let me take another stab at it...

             

            How can I find out what custom views have been created for a given workbook via one of the Tableau's API's?  I am basically trying to recreate the custom view drop down that's native within Tableau Server in a custom web app.

             

            I don't even know if it's possible to get that information via an API.  I know the rememberCustomViewsAysnc(<name>) returns a promise for the POST made, but that doesn't necessarily mean that I can retrieve a list of previously remembered views.  I'm thinking I might only be able to get at that information by querying the postgres database.

             

            You're help with this is greatly appreciated!

            • 3. Re: Does anyone know how to return the object containing all Custom Views that have been remembered?
              Russell Christopher

              rememberCustomViewsAsync() essentially creates a custom view. You fire getCustomViews() against a workbook, and it'll return all the custom views that have been created against it (either "manually" by users or via rememberCustomViewsAsync())  - I think this is what you want based on what you've said

              • 4. Re: Does anyone know how to return the object containing all Custom Views that have been remembered?
                Robert Crocker

                Then my struggle is writing a proper callback function.


                viz.getWorkbook().getCustomViewsAsync().then(function() {})


                I can run the code above with or without the .then and I get...

                tab__PromiseImpl {then: function, always: function, otherwise: function, constructor: function}

                     then: function () {

                          _targets: Array[2]

                          0: tab__DeferredImpl

                          1: function tab__DeferredImpl$then(callback, errback) {

                               arguments: null

                               caller: null

                               length: 2

                               name: "tab__DeferredImpl$then"

                          prototype: tab__DeferredImpl$then

                          __proto__: function Empty() {}

                          <function scope>

                               Closure

                               Global: Window

                                    Infinity: Infinity

                                    AnalyserNode: function

                                    AnalyserNode() { [native code] }

                                    ApplicationCache: function

                                    ApplicationCache() { [native code] }

                                    ApplicationCacheErrorEvent: function ApplicationCacheErrorEvent() { [native code] }

                                    Array: function Array() { [native code] }

                                    ... returned to the console


                Any additional advise on how to handle this promise would be great.  I get lost in tab_PromiseImpl.


                I also declared a variable called promise by writing...

                var promise = viz.getWorkbook().getCustomViewsAsync()


                then I ran...

                promise.then.name


                .then.name returned an empty string (""), but I know there are three custom views assigned to this workbook.


                Thanks again!

                • 5. Re: Does anyone know how to return the object containing all Custom Views that have been remembered?
                  Robert Crocker

                  You're right about the getCustomViewAsync().  Sorry it took me so long to get it.

                   

                  Now how do I get that collection of custom views to fall into a nice array?

                   

                  If I could figure out how to parse that promise would be alright.

                  • 6. Re: Does anyone know how to return the object containing all Custom Views that have been remembered?
                    Robert Crocker

                    I was hoping to find an example where you parse it apart in your code from this great example (Tableau v8.2 JavaScript API), but you it looks like you don't use the getCustomViewsAsync() method anywhere