Skip to Content
Author's profile photo Former Member

How to set a WEBI document to autorefresh each n seconds

Hi,

there are a lot we can acomplish using Javascript from within a WEBI document. But it will only work if your viewwing the document through the HTML client.

For this first blog post, I will show how to set a Document to autorefresh itself each n seconds.

What you have to do is :

– Create a Document and set it to refresh on open;

– Drag a blank cell over the report and set its text to

  <script>

  self.parent._askConfirmationBeforeClosingDoc=false;

  setInterval(function(){window.parent.parent.location.reload();},n*1000);

  </script>

where n is the number of secons to refresh,

Save the report.

Re-open , right click on the blank cell inserted , choose ‘Format Cell’ and under ‘Read content as’ choose HTML.

Save the report again.

That´s it, it will refresh each n seconds without manual intervention.

Cheers,

Rogerio

It works in both BO 3.1 and BO 4.x

Assigned Tags

      80 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rodrigo Silveira
      Rodrigo Silveira

      Hi Rogerio, nice post !!!

      Do you have any example of script to change a tab to another tab on the same web i ?

      Regards,

      Rodrigo

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

      Hi Rodrigo,

      thank you for your comment. What do you mean by changing tab to another tab ?

      Is it like going to another tab on the same report (you´re viewing tab 1 then press a buttom and it switchs to tab 2?

      Cheers,

      Rogerio

      Author's profile photo Rodrigo Silveira
      Rodrigo Silveira

      Exactly Rogerio, this behavior.

      I need create a link to go for tab1, tab2, etc ... (it's possible do with opendocument too, but the opendocument refresh the page)

      So, i need create a js to jump to another tab on the same document ...

      Thanks,

      Rodrigo

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

      Hi Rodrigo,I´ve never done this befor, but I think it´s feasible. Need to try it.

      Cheers,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Hi.

      I think, You can use the script given by Plank on the new report ( TAB ) which you are supposed to jump.

      while configuring document linking check the refresh on open option.

      Refer to this doc.

      http://scn.sap.com/message/16024057#16024057

      Thanks

      Santhosh.

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

      Hi Rodrigo,

      I´ve just came out with the answer to your question.

      The script to change from one report to another is

      <script>

      this.parent.selectReport( n );

      </script>,

      where n is the position of the tab (0,1,2, 3,etc..).

      If you´re on reading mode, change it yo

      <script>

      this.parent.parent.selectReport(4);

      </script>

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Hi Rogerio

      How did you find out the command/function to use for switching tabs, is there a resource online which lists the available functions or a way to view them through something like firebug?  I'm interesting in finding out what else we can do with Javascript.

      Cheers

      David

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

      HI David, thanks for your interest. No, there isn't any online resource, what I did was launching the html client and use the browser developer tools to trace the application.

      I won't lie to you is a hard work, but I think it's a very interesting. Sometimes you find some valuable resource.

      IF you want, we can work together to discover new applications,

      CHeers,

      ROgerio

      Author's profile photo Former Member
      Former Member

      Thanks Rogerio, like you say it's not easy but can be very interesting and hopefully opens up new possibilities.

      At the moment I'm only just starting to learn about the use of Javascript and how it works with everything else, so I have a lot more to learn than I have to share but if I find anything useful I'll certainly share it with the community.

      Cheers

      David

      Author's profile photo Rodrigo Silveira
      Rodrigo Silveira

      Try this ...

      <script type="text/javascript">

      // Rodrigo Silveira

      //rodrigosilveira7@gmail.com

      function _jump(v_report)

        {

        var v_lines = self.parent.DS.arrReports.length;

        var v_id = 0;

        for (var i = 0; i < v_lines; i++)

        {

        if(v_report == self.parent.DS.arrReports[i].name)

        {

        v_id = self.parent.DS.arrReports[i].reportID;

        }

        }

        var v_idx = self.parent.getReportIdxFromId(v_id);

        self.parent.selectReport(v_idx);

        }

      </script>

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

      Hi Rodrigo thanks for helping!!!

      Cheers,

      Rogerio

      Author's profile photo Rahul Verma
      Rahul Verma

      Hi Rogerio,

      I wanted to jump to another tab within same document.  I tried your script in HTML mode:

      1. Set the document refresh on open then create a new cell.

      2. Edit formula, enter the script, validate, save.

      3. Re-open the Report, then set the cell as HTML.

      4. Run the report, click on the cell - nothing happens.

      Is there anything missing?

      thank you in advance, Rahul

      Author's profile photo Rahul Verma
      Rahul Verma

      This does not work for me in BI4.1

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

      Hi Rahul,

      I´m so sorry taking so long to answer you ...

      Which script you´re talking about ?

      I´ve just tested the autorefresh script on BO 4.1 SP5 and it´s working just fine.

      Can you give more details on what´s happening ?

      What I can tell you in advance is that between steps 3 and 4, you need to save the DOC again.

      Regards,

      Rogerio

      Author's profile photo Rahul Verma
      Rahul Verma

      Hi Rogerio,

      I tried the script to change from one report to another:

      <script>

      this.parent.selectReport( n );

      </script>

      Give me an hour, I will mention step by step what I did.

      Author's profile photo Rahul Verma
      Rahul Verma

      Hi Rogerio,

      I am so sorry that my one hour lasted so many days πŸ˜†

      Actually, here is what I follow

      Step 1.  I add another tab in a report and add blank cell.

      Step 2.  I set refresh on open and set the blank cell with the script - see screenshot

      Step1.JPG

        Step 3.  Click Save

        Step 4.  Set the Cell to be read as HTML and Save

        Step 5.  Verify the Viewer under preferences

        Step3.JPG

          Step 6.  Now if I click the cell, nothing happens.  As if we did nothing.

      StepsLast.JPG

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

      Hi Rahul,

      I´m sorry for taking so long to answer. What is strange is that, doing as you told us, you shouldn´t see what´s on your last picture. The cell must show nothing.

      Regards,

      Rogerio

      PS : I attached a sample WEBI file (.wid) as an example . It´s on WEBI 4.1  SP5. I change the extension from .wid to .txt so I can post it here

      Author's profile photo Rahul Verma
      Rahul Verma

      Thanks and just for others who read this - Is it this report name that you have attached

      Change Report.txt.zip (7.8 K) at the top?

      Author's profile photo Former Member
      Former Member

      Hi Rahul,

      In order to work you have to write an entire script How to jump to a different report dynamically and launch it into BI Launch pad.

      Regards

      Nidhi

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      I also got the same error as Rahul is getting. Are we doing something wrong? As what you say we should not see what is written in formula but when we write that script in formula we can see that as shown by rahul. I am trying on jump tab script. Could you please guide.

      Thanks

      Nidhi

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      I tried your attached sample web intelligence even that seems not working for me πŸ™ . Could you please guide , your script is also clearly visible as told by you it should not be visble <input_type = "button" value = "Go to report2"......

      Regards

      Nidhi

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

      Hi Nidhi,

      In order to work you must export the document to BI Launch Pad?

      Regards,

      Rogerii

      Author's profile photo Former Member
      Former Member

      Thanks Rogerio it works πŸ™‚

      Author's profile photo Former Member
      Former Member

      Hello Rogerio : Thanks for sharing the script. As i am new to the webi can you please tell me, how i can

      Create a Document and set it to refresh on open; ?

      - Drag a blank cell over the report and set its text to ?


      Thanks,

      Srikanth.

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

      Hi Srikanth,

      Sorry , I just see you message today. The steps are :

      Set the document proporty Refresh on Open checked



      refresh on open.png



      Drop a blank cell on the report



      drop a blank cell.png




      Set it´s value to the script




      set text.png




      Set the cell´s Read content  as to HTML



      cell property.png





      Regards,

      Rogerio



























      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      This works really good. But I have a small problem with IE. Everytime that the page refreshes IE displays a popup:

      /wp-content/uploads/2015/09/warning_798823.jpg

      then the user has to click to refresh the page. Any idea how to get around or disable this message?

      Thanks,

      Edwar

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

      Hi Edwar,

      Thanks for your comment. There must be a variable that control it.

      I'll check and let you know.

      Regards,

      Rogerio

      Author's profile photo Rahul Verma
      Rahul Verma

      Hello Rogerio,

      Just curious, do you see if I missed anything.  Please reply.

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      I couldn't found anyhting to disable the warning message. Any idea how to disable the warning message from the browser? It seems like I am the only one that have this problem. Looking at other post in this blog nobody else get the message.

      Thanks for your help!

      Edwar

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

      Hi Edwar,

      the line self.parent._askConfirmationBeforeClosingDoc=false should suffice. Are you seeing the report in reading or designing mode?

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

            In designing mode it works fine (I don't get the warning message), but as soon as the users run the report in reading mode, they get the warning message.

      Thanks,

      Edwar

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

      Hi,

      the HTML structure of designing and reading mode is quite different. I´m sorry , I should had adviced., for reading mode, you have to add an extra parent.after self. So it will become

      self.parent.parent._askConfirmationBeforeClosingDoc.


      So, in order to that functions on both reading and designig mode, we should test wether one is in reading or designig mode :


      test  self.parent.isInteractive, if this value is true, means that you´re on design mode and you can use the script as written. If is not, you´re on reading mode and need to use an extra parent , so the script will turn to :

        self.parent.parent._askConfirmationBeforeClosingDoc=false;

        setInterval(function(){window.parent.parent.parent.location.reload();},n*1000);

      Regards,

      Rogerio



      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

            Thank you for taking the time to investigate this issue. I tried your last suggestion but it didn't work. I am still getting the warning message in reading mode.

      In design mode works fine. Just a note: in design mode works fine even without the "self.parent._askConfirmationBeforeClosingDoc=false;". I also changed the value to true (in design mode) to see if I get the warning message and I didn't get it.

      Here is that I have inside the blank cell;

      <script>

        if (self.parent.isInteractive == true)

          {

           self.parent._askConfirmationBeforeClosingDoc=false;

           setInterval(function(){window.parent.parent.location.reload();},20*1000);

          }

        else

          {

         self.parent.parent.parent._askConfirmationBeforeClosingDoc=false;

         setInterval(function(){window.parent.parent.parent.location.reload();},20*1000);

          }

      </script>

      I appreciate any suggestion.

      Thanks,

      Edwar

      Author's profile photo Former Member
      Former Member

      You are simple superb man. Bless you dude'

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

      Thanks 😳 😳

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      Awsemoe script...

      thanks,

      amrendra

      Author's profile photo Former Member
      Former Member

      Really useful Script Rogerio.


      Thanks

      Sateesh

      Author's profile photo SHEETAL SHARMA
      SHEETAL SHARMA

      Nice Document Rogerio, Thanks for sharing!!

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      very good script ....it will useful,Thanks for sharing .

      Regards

      Narasimha

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      Very useful document to make it simple. Thanks for sharing.

      Author's profile photo Koen Hesters
      Koen Hesters

      Great stuff

      Author's profile photo Anthony MULLER
      Anthony MULLER

      Hi Rogerio,

      Did you try to do the same using the official Web Intelligence Extension API (working on both Webi clients)?

      Best regards,

      Anthony

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

      Hi Anthony,

      thanks for your response. I did not because it implies in asking the IT crew to enable the extensions , is this right ?

      And there are a HR policy that people outside IT could not program 😑 😑 . As I´m outside IT crew, it would not be possible (unfortunately πŸ˜₯ πŸ˜₯ ), so I´m trying to achieve things exclusively from client side , without the interference of the IT people.

      Cheers,

      Rogerio

      Author's profile photo Anthony MULLER
      Anthony MULLER

      Thanks for explaining this context, you're right about the need of IT people to activate extension.

      That's interesting to understand this kind of "issues" from customers side.

      Best regards,

      Anthony

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

      And that´s why I asked about the bttoken on the Restful space. By inserting the Javascript into the WEBI document you can make use of the Restful API and set the document to modify itself.

      By the way, is it possible to post a Document in both spaces (Web Intelligence and Restful) ?

      Cheers,

      Rogerio

      Author's profile photo Anthony MULLER
      Anthony MULLER

      I don't know about posting in several space, maybe a SCN guru will know πŸ™‚

      About the workflow you were talking about, it would be not possible to modify the document itsefl using RESTful API from Webi HTML client. Indeed, RESTful API and Webi HTML client are not deployed in th same container (BOE vs WACS) and thus don't share the same memory space.

      The only way to interact with a document opened in a Webi client (HTML or Java) is to use Web Intelligence Extension API (a Javascript API). But, as you noticed, that implies to have been granted to deploy extensions.

      Best regards,

      Anthony

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

      That´s why a posted the documents of refreshing and saving WEBI documents.

      Here is the workflow I´m following in order this to work so far :

      1 - Get thew logontoken with the Rest API;

      2 -Open the document through OpenDocument passing the logontoken as a parameter (How to pass a parameter to a WEBI doc  );

      3 - Make the Rest call to alter the document, include a variable for instance;

      4 - Save the doc (How to autosave a Document over itself each n seconds);

      5 - Refresh it (How to set a WEBI document to autorefresh each n seconds).

      Saving and refreshing the document re-loads the document, since you have altered it and saved, the reload will get the new document version.

      Possible uses : Use interactive charts   charts (Assigning specific colors to selected data series on a chart)  and get the user input through a variable.

      The downside here is that , if the document is too complex it can take some time to reload.

      I´ve submitted a session for ASUG in Orlando this year just about it.

      I would like to hear your opinion on it.

      Cheers,

      Rogerio

      Author's profile photo Anthony MULLER
      Anthony MULLER

      As you noticed, the mail issue about a such workflow is the performance since it requires to reload the document many times.

      To do something more efficient, you should avoid to use OpenDoc.... maybe by implementing a kind of document viewer based on RESTful API?

      Author's profile photo Former Member
      Former Member

      Hello Rogerio,

      very usefull script. thanks !

      Do you have such a script to update local excelfile used as "local document".

      "replace" functionnality is not really convenient.

      Any idea ?

      br

      Laurent

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

      Hi Laurent,

      what do you mean by update the local file ?

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      I use a Microsoft Excel as data source for Web Intelligence.
      For that, I have created a Local document, uploading an excel file.
      (this excel file contents a list of specific orders)
      Then, I use this local document as a filter in WebI querry, the purpose is to pick up all specification of this order list.
      It works, but my issue is the local excel file is updated every day (from a querry not through WebI), and I can't just "refresh" the content of this excel file in WebI, I have to "Replace" it (Replace, Browse, ...) despite location and name of this excel file is the same.
      This is not efficient, nor convenient. It's the reason why I try to find a better way.

      If I am not clear, see :  http://scn.sap.com/docs/DOC-49324
      Replace file is described in "Maintaining your Microsoft Excel Spreadsheet" paragraph.

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

      Hi,

      take a look at

      Creating a Webi doc off of an unmanaged Excel data source on a network share

      This can help you, otherwise we can try other solution.

      Cheers,

      Rogerio

      Author's profile photo Anthony MULLER
      Anthony MULLER

      Hi guys,

      We are working on a feature to update the Excel file content directly on the InfoObject using RESTful API. So, no other manipulation than a data refresh would be required from Webi side πŸ™‚

      Regards,

      Anthony

      Author's profile photo Former Member
      Former Member

      Hello Rogerio,

      Good idea πŸ˜‰

      thanks for this script.

      Regards,

      Nafti

      Author's profile photo WILLIAM MARCY
      WILLIAM MARCY

      Great Webi trick !

      You've been added to Webi 4.x tricks : summary for a better visibility. Keep posting !

      William

      Author's profile photo Former Member
      Former Member

      Hi,

      Thanks for the script!

      I work with boxi 3.1

      In reading mode this message apears on refresh.

      In design mode the report do not refresh

      any advice?

      thanks,

      /wp-content/uploads/2015/12/err_842593.png

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

      Hi Ben,

      Do me a favor ? At your browser press CTRL+F12, this will bring up the developer tools.

      Click on Console and attach a printscreen of this so we can figure out whats happening.

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      I hope this is what you meant:

      /wp-content/uploads/2015/12/scr1_843236.png/wp-content/uploads/2015/12/scr2_843237.png/wp-content/uploads/2015/12/scr3_843238.png

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

      Hi,

      no , I mean click on Console, the window being shown is Script.

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Console window is empty πŸ™

      /wp-content/uploads/2015/12/scr4_843487.png

      Author's profile photo Former Member
      Former Member

      Hi,

      I have a few questions to see if this is really a usable option for us.

      Will this keep using the same session or will it create a new one for every refresh? I assume it keeps using the same user session. Which is good.

      Will i be able to keep this report open or will i hit timeouts due to inactivity (tomcat,CMS,....)?

      Kind regards

      Laurens

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

      Hi Laurens, thanks for your comments.

      It will keep the same user session.

      Since it throws a request to the server , it won´t get timeout at WEBI.

      If your intent is to avoid timeout, I suggest you go over this post.

      How to avoid timeout when viewing a WEBI Document

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Hi,

      Thanks for the swift reply.

      As an administrator i'm a fan of the timeout principle. We don't want people to keep alive their session forever for obvious reasons. But it's an interesting workaround. πŸ˜‰

      We would need this piece of code to mimic the auto-refresh feature from DeskI/Dashboards.

      This helps us quite a lot. Thanks for sharing!

      Kind regards

      Laurens

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

      You´re mostly welcome !!!

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Hi Rogerio

      we have experienced the same issues as Edwar lara in that we are prompted to confirm reload by chrome and asked to leave the page in IE. Are there any workarounds for this? We tried what you suggested to Edwar and that also didn't work for us.

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

      Hi Shane,

      what version of webi you´re on ?

      Regards,

      Rogerio

      Author's profile photo Former Member
      Former Member

      Hello Rogerio,

      We are using Webi XI 3.1 on SP4.

      Best Regards,

      Shane

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      do you have any further feedback on the confirm reload issue?

      Best Regards,

      Shane

      Author's profile photo Former Member
      Former Member

      Supressed the leave page messages by applying and denying  the following security rights in the CMC :

      Add objects to the folder
      Add objects to the folder that the user owns
      Copy objects to folder
      Copy objects to the folder that the user owns
      Edit objects
      Edit objects that the user owns

      The access level should be applied to the folder associated with the report.

      See Suppress &amp;#8220;Are you sure you want to navigate away from this page?&amp;#8221; message box | My Notepad-Blog

      So now the refresh works in IE and Chrome without any leave messages. Perfect. Many thanks for sharing the  java script.

      Best Regards

      Shane

      Author's profile photo Former Member
      Former Member

      thanks for the script. it works great. we have report with input controls and every time it refreshes the input control selections defaults to original saved. is there a way to keep input controls selection intact and still have this script refresh webi.

      thanks

      Author's profile photo Former Member
      Former Member

      Hi Rogerio,

      I tried it with BO 4.2 and it does not work:(

      Can you please help?

       

      Thanks,

      Dikla

      Author's profile photo Santhosh Kumar Alladi
      Santhosh Kumar Alladi

      Hi Rogerio, Wonderful post and we used your script in BI4.1 SP06 but now the script doesn't work any more in BI4.2 SP03 (Patch 02 or Patch 05). Do you know what's the reason and how to fix it?

      Author's profile photo Former Member
      Former Member

      It works fine in BI 4.2 SP03 Patch03 (14.2.3.277).

      Script didn't work for me, but then i changed time parameter :

      setInterval(function(){window.parent.parent.location.reload();},10000);

       

      I have another question: Can we add to this script pressing Enter button ?

      My report contains parameters with default value, i got annoyed when the screen with parameters appears. And I need only press Ok to start the report. Any ideas ?

      Author's profile photo Former Member
      Former Member

      Hi,

      We are using this on BI4.1 SP2 for quite a while now and has always worked perfectly.

      Now we are testing the upgrade to BI4.2 SP4 and see this is no longer working. Anybody a similar experience?

      We did not change anything in the reports.

      Kind regards

      Laurens

       

      Author's profile photo Former Member
      Former Member

      Update: We needed to enable javascript in the webintelligence application via the CMC.

       

      Enable Javascript
      Author's profile photo Former Member
      Former Member

      Yes, after enable it, this script works in 4.2.

      Author's profile photo Former Member
      Former Member

      Hi Rodrigo,

      Thank you for script.

      It is possible that we also display the last refresh time to user?

       

      Author's profile photo Mirko Nowotzin
      Mirko Nowotzin

      Hello,

      JavaScript functionality is available for the standard HTML viewer.
      Is this also possible for the Fiorified BI Launchpad viewer?

      Thanks and regards,
      Mirko

       

      Author's profile photo Ton Vermeij
      Ton Vermeij

      Hi all,

      Just started at t e SAP BI role at a new company. In our Webi reports we use the same HTML script for some reports that are presented and refreshed for quite a long time every day. So a webi report is displayed on a big screen and is refreshed automatically every N seconds. Nice solution.

      But I suspect it has a consequence for the TomCat server. It looks like this refreshing technique fills attacks the memory of the Tomcat server because it keeps all instances of the resfreshed report.

      Does anyone knows or recognises this problem. At this time every week we stop and start the Tomcat Server to prevent it hanging:(

       

       

      Author's profile photo Juliana Galarraga
      Juliana Galarraga

      Hi Rogerio!

      Amazing post!! ^__^

      Does anyone know how to set user prompts (Prompt Window) values automatically through javascript? I got my report to refresh each n seconds, but since it has prompts, the prompt window appears each n seconds as well.

      Thanks and kind regards,

      Juliana