Refresh the harness periodically when it is an active thread

We have written a javascript to reload the harness periodically that gets called when the harness is loaded. Currently we are using Settimeout function to reload the page. Our requirement is to refresh the harness only when it is active thread in UI, but this function is executing even when the user traverses to other harness (Review or Dashboard or Reports). Now, when ever the user traverses to other menu items in the portal, this harness thread is still in the background and the script is executing continuously.

Is there any other way we can refresh the harness periodically when it is active (Displayed in UI) and not refresh it if it is not active thread?


Keep up to date on this post and subscribe to comments

August 9, 2019 - 7:08pm

The function pxGetThreadIDForActiveUI uses that to find the active thread.

Can you reload the harness based on the active thread?

August 12, 2019 - 4:51pm
Response to SusanLiu

Thank you for the response. I am able to get the active thread in UI. For comparing the thread names, I need to store the threadname of harness in a requestor level page (so that it can be accessible by different threads.) For now, I am using operator id page and my function is executing properly. Do you know of any other alternatives to pass the data between the threads and store the thread name temporarily on a requestor level page.  

August 12, 2019 - 1:05am

There is a javascript method SetInterval method which can be used. 

"The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).

The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed."

In this method, you can keep an 'if condition' - "when it is active thread

August 16, 2019 - 1:59pm
Response to Rachit_Agarwal

Hi, My code is failing in one scenario. As the java code is in scriptlet, it looks like the code in else loop is executing as well when the setinterval is loaded.  I can see the pylabel value as "Hello" in clipboard. Any other way to write jsp code to use java for comparison


Here is my sample code:

var HarnessThreadName =  "<%= tools.findPage("OperatorID").getProperty(".pyLabel").getStringValue() %>"; //Checking if my requestor page has a value

  if (HarnessThreadName==""){



  String HarnessThreadNameChk = pega_wb_clipboardviewer.pxGetThreadIDForActiveUI();

ClipboardPage PageName= tools.findPage("OperatorID.EntitlementInfo");  // Get Clipboard Page

PageName.putString(".pyLabel",HarnessThreadNameChk);  // Set Value to Property


var HarnessThreadName = "<%= tools.findPage("OperatorID").getProperty(".pyLabel").getStringValue() %>";



   var ActiveThreadName = "<%= pega_wb_clipboardviewer.pxGetThreadIDForActiveUI() %>";


setInterval('window.location.reload()', 15000);




     alert("Threads do not match");


  ClipboardPage ReqPageName= tools.findPage("OperatorID"); 

ReqPageName.putString(".pyLabel", "Hello");