Skip to Content
Author's profile photo Former Member

How to autosave a Document over itself each n seconds

Hi ,

In WEBI 4.x there is a functionality that autosaves the document that you working on in the ~WebIntelligence folder under My Favorites.

But what if you need to save it overitself, just like you´rte pressing the save button.

Steps :

– Drop a blank cell onto the report;

– Set it´s value to :

       <script>

        setInterval(function () { self.parent.save();} , n*1000);

        </script>,

where n is the number of seconds to the autosave


– Set the cell´s property “Read As” to HTML.

Cheers,

Rogerio

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Thanks for posting this Rogerio, I've been messing about with it and it does usually work but had a couple of questions, wondered if you could help me with them?

      First, this doesn't work if the Outline view is turned on, Firebug returns the error 'typeerror: self.parent.save is not a function', interestingly using 'alert(self.name);' returns 'Report' when Outline view is turned off and 'Reportbloc' [sic] when Outline view is turned on.  Do you know if there is a more explicit way to reference the report?

      Secondly, I've found it can cause problems if self.parent.save fires while refreshing the query/queries, do you know if there is a way to test if the document is being refreshed and only fire the save when it isn't?  I've had a look but I can't see anything.

      Cheers

      David

      Author's profile photo Former Member
      Former Member

      I managed to put together a script which both works with or without Outline view turned on and doesn't save the document when a dialog box is open (as I found it wasn't just the refresh dialog which caused problems).  So far it's working pretty well but I think there's still plenty of scope for improvement.

      <script>

        setInterval(function() {

          switch(self.name) {

            case "Report":

              if(self.parent.DialogBoxWidget_currentCount==0) {

                self.parent.save();

              }

              break;

            case "Reportbloc":

              if(self.parent.parent.DialogBoxWidget_currentCount==0) {

                self.parent.parent.save();

              }

              break;

          }

        }, 10*60*1000);

      </script>


      David

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      HI David,

      great!,

      WHy don't we work together in order to produce more and better scripts?

      REgards,

      Rogerio

      Author's profile photo Alfonso R. Arancón Domínguez
      Alfonso R. Arancón Domínguez

      Hi Rogerio.

      This script in my case does not work, the script to auto-refresh works perfectly and in fact I use it, however this simply does not do anything.
      What could be the problema?
      EDIT.
      Ops! I've already seen that the autosave does it without indicating anything, let's face it, it works.

      Could you join the auto-refresh script and the auto-save script? And if it were possible, could I do the auto-save in Excel format?