UI Page reloadWindow() ONLY UI Page window

xiaix
Tera Guru

I have a widget on my homepage.   It's just a simple UI Page that pulls some stats.   I want this widget (ui page) to refresh independently of   everything else.   Very similar if not the same how a live feed would work.

Here's an example of what I have:

<script>

        function reloadThisWindow()

        {

                  reloadWindow(window);

        }

</script>

<table>

        <tr>

                  <td>

                            Yadda yadday some dynamic stuff pulled from a GlideRecord

                  </td>

        </tr>

</table>

<script>setInterval(function () {reloadThisWindow()}, 10000);</script>

This reloads the entire page every 10 seconds, but I need it to only reload this UI Page (widget), NOT the whole page.

I tried reloadWindow(this); but it too reloaded the entire page.

What parameter can I pass to tell it to only reload this ui page?

6 REPLIES 6

In case someone doesn't have Service Portal yet and would like to do this in a UI Page.



Instead of reloading the whole page target just the element. Below is a basic example.


For instance if there was a client callable script include that gets the priority 1 incidents and I wanted to have the list refresh every 5 seconds.


UI Page:


html/xml:


        <div>


              <ul id="priority_ones" style="list-style: none"></ul>


      </div>



client script:


setInterval( function() {


        var ga = new GlideAjax('incUtilsAjax');


        ga.addParam('sysparm_name', 'getPriorityOnes');


        ga.getXML(function(response){


                      var answer = response.responseXML.documentElement.getAttribute("answer");


                      var inp = gel('priority_ones');


                      var list = JSON.parse(answer);


                      var li = [];


                      list.forEach(function(item){


                                li.push('<li>'+item.name+'-'+item.login_time+'</li>');


                      });


                      inp.innerHTML = li.join("");


        });


}, 5000);



Or a button can be used to manually refresh if you wrap in a regular function and not a setInterval(). Then just use an onclick/eventListener to call the function.


I didn't go the timer route, but I did this:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


      <g2:client_script type="user" />


      <script>


              addLateLoadEvent(function(){


                      build_the_widget();


              });


      </script>


      <style>


              .trHover tr:hover td {background:#d7d7d7;}


      </style>


      <div id="tick"></div>


      <table id="roundRobinWidgetTable">


              <tr>


                      <td>


                              <table id="RR_users_table" class="trHover"></table>


                      </td>


              </tr>


      </table>


</j:jelly>



In the client script, the build_the_widget() function does all the heavy lifting, populating roundRobinWidgetTable and RR_users_table.