Skip to Content

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

To report this post you need to login first.

77 Comments

You must be Logged on to comment or reply to a post.

    1. Rogerio Plank 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

      (0) 
      1. 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

        (0) 
        1. Rogerio Plank 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

          (0) 
          1. David Pentland

            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

            (0) 
            1. Rogerio Plank 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

              (0) 
              1. David Pentland

                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

                (0) 
                1. 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>

                  (0) 
          2. 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

            (0) 
            1. Rogerio Plank 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

              (0) 
              1. 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.

                (0) 
              2. 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

                (0) 
                1. Rogerio Plank 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

                  (0) 
                  1. Nidhi Aggarwal

                    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

                    (0) 
                  2. Nidhi Aggarwal

                    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

                    (0) 
      2. srikanth baburao

        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.

        (0) 
        1. Rogerio Plank 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



























          (0) 
          1. Edwar Lara

            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

            (0) 
              1. Edwar Lara

                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

                (0) 
                1. Rogerio Plank Post author

                  Hi Edwar,

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

                  Regards,

                  Rogerio

                  (0) 
                  1. Edwar Lara

                    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

                    (0) 
                    1. Rogerio Plank 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



                      (0) 
                      1. Edwar Lara

                        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

                        (0) 
    1. Rogerio Plank 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

      (0) 
      1. 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

        (0) 
        1. Rogerio Plank 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

          (0) 
          1. 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

            (0) 
            1. Rogerio Plank 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

              (0) 
              1. 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?

                (0) 
  1. l brunel

    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

    (0) 
      1. l brunel

        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.

        (0) 
        1. 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

          (0) 
  2. Ben Weinfeld

    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

    (0) 
    1. Rogerio Plank 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

      (0) 
  3. Laurens Verstraeten

    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

    (0) 
      1. Laurens Verstraeten

        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

        (0) 
  4. Shane Feldman

    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.

    (0) 
  5. Shane Feldman

    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

    (0) 
  6. harsha kolan

    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

    (0) 
  7. 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?

    (0) 
  8. Vasilij Shutko

    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 ?

    (0) 
  9. Laurens Verstraeten

    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

     

    (0) 

Leave a Reply