2 Replies Latest reply on Nov 23, 2013 5:48 AM by Russell Christopher

    Tableau Javascript API: Set a viz state to advertised?

    J K

      When saving a viz state using the rememberCustomViewAsync() function, how does one designate it as an advertised version?
      I see a setAdvertised() function, but no indication as to how it would be used in conjunction with rememberCustomViewAsync.

        • 1. Re: Tableau Javascript API: Set a viz state to advertised?
          J K

          *bump*

           

          Here's what I have, but it doesn't work. Help?

           

          workbook.rememberCustomViewAsync('my viz id')

            .then(function(cv) {

              cv.setAdvertised();

            });

          • 2. Re: Re: Tableau Javascript API: Set a viz state to advertised?
            Russell Christopher

            I wrote this code ages ago, so don't really remember how it works

             

            But it seems you need to call Save on the workbook again after advertising it, and you need to pass true into the setAdvertised method....

             

             

            function customView() {
              mainWorkbook = mainViz.getWorkbook();
            
              var onSuccess = function (view) {
              newCustomView = view;
              };
              var onError = function (err) {
              alertOrConsole("Whoops");
              };
            
              mainWorkbook.rememberCustomViewAsync("Test2").then(onSuccess, onError);
            }
            
            function saveAsync() {
            
              // I'm being lazy and and assuming rememberCsutomViewAsync (above) was just called and that 
              // newCustomView is defined with a valid value
              newCustomView.saveAsync().then(function () {
              alertOrConsole("The URL for this new view is :" + newCustomView.getUrl());
              });
            }
            
            function setAdvertised() {
            
              // Allows other people to see this custom view  
              newCustomView.setAdvertised(true);
              //Re-Save
              newCustomView.saveAsync();
            }