Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

SessionTimer control is not working

SA-6986

Summary



Session Timer control that user migrated from 6.2 to 7.1 is not working correctly. They have a script in the section and then they embed that section in a portal harness. Then they configure the parameters for the section accordingly. After the session timeout a popup should come up, but it does not.

Error Messages



N/A

Steps to Reproduce



Refer the below script in a section and embed that section in a portal harness. Configure the parameters for the section accordingly that after the session timeout a popup should come up.

<% /* BEGIN : REQUIRED FOR GADGET FUNCTIONALITY. DO NOT TOUCH BELOW LINES.*/%>
<pega:when test="pxRequestor.pyPegaDesignMode == 'true'">
<%ClipboardPage pyDefaultParams = tools.createPage("PegaGadget-SessionTimeoutMgr","myParamPage");
pyDefaultParams.adoptXMLForm("<?xml version=\"1.0\"?><pagedata><pxObjClass>PegaGadget</pxObjClass></pagedata>");%>
</pega:when>
<pega:include name='pzGadgetInclude'/>
></div>


<% ClipboardPage pyPortalPage = tools.findPage("pyPortal");
ClipboardPage myParamPage = tools.findPage("myParamPage");
String pyTimeoutTime = myParamPage.getString("pyTimeoutTime");
String pyTimeoutWarningWindow = myParamPage.getString("pyTimeoutWarningWindow");
String pyTimeoutPopupType= myParamPage.getString("pyTimeoutPopupType");
String warningMsg = tools.getLocalizedTextForString(".pyMessageLabel","TimeoutWarning");

pyPortalPage.putString("pyTimeoutTime",pyTimeoutTime);
pyPortalPage.putString("pyTimeoutWarningWindow",pyTimeoutWarningWindow);
pyPortalPage.putString("pyTimeoutPopupType",pyTimeoutPopupType);
%>

<script>

pega.d.TimeoutTime = '<%=pyTimeoutTime%>';
pega.d.TimeoutWarningWindow = '<%=pyTimeoutWarningWindow%>';
pega.d.TimeoutPopuptype = '<%=pyTimeoutPopupType%>';
pega.d.TimeoutWarningCountdown = null;
pega.d.TimeoutPopupHeight = "<pega:lookup className="Rule-Obj-FieldValue" property="pyLocalizedValue"><pega:key name="pyClassName" value ="Rule-Portal" /><pega:key name="pyFieldName" value="pyTimeoutPopupType" /><pega:key name="pyFieldValue" value="WindowHeight" /></pega:lookup>";
pega.d.TimeoutPopupWidth = "<pega:lookup className="Rule-Obj-FieldValue" property="pyLocalizedValue"><pega:key name="pyClassName" value ="Rule-Portal" /><pega:key name="pyFieldName" value="pyTimeoutPopupType" /><pega:key name="pyFieldValue" value="WindowWidth" /></pega:lookup>";
pega.d.TimeoutWarning = '<%=warningMsg%>';


function desktop_restartTimeoutWarningTimer(){

  if (pega.desktop.TimeoutTime && pega.desktop.TimeoutTime > 0) {
  /* Calculate the time to initial warning in milliseconds*/
  var nTimeoutWarningTime= (pega.desktop.TimeoutTime - pega.desktop.TimeoutWarningWindow) * 60000;

   /* Clear the existing countdown */
   clearTimeout(pega.desktop.TimeoutWarningCountdown);
    if (nTimeoutWarningTime >= 0) {
       pega.desktop.TimeoutWarningCountdown = self.setTimeout("desktop_showTimeoutLogoffDialog('"+pega.desktop.TimeoutWarningWindow+"')",nTimeoutWarningTime);
    }
  }
}

</script>
<pega:include name='pzGadgetInclude_End'/>
<% /* END : REQUIRED FOR GADGET FUNCTIONALITY. DO NOT DELETE ABOVE LINE.*/%>


Root Cause



The root cause of this problem is a defect in Pegasystems’ code/rules. 

As part of 7.1.7 the usage of window.showModalDialog was altered because chrome and firefox no longer support it.

This included modifying the desktop_appControllerLite.js:desktop_showTimeoutLogoffDialog to use pega.openUrlInModal.showModalDialog.

There is a syntax error with oSafeURL within the pega.openURLinModal.showModalDialog call, "oSafeUrl" is used instead of "oSafeURL". (Bold below)

Once that is corrected this does display the timeout dialog in the modal div created by pega.openUrlInModal. However, the actual functionality of logging the user off when the timer is done counting down is not working. The timer starts to go into negative numbers, logoff never occurs. Also, the okay button does not work, should close the modal div and and restart the timer.


function desktop_showTimeoutLogoffDialog(strTime) {
   var iTime = parseInt(strTime);
   iTime = iTime * 60000;
   var oSafeURL = new SafeURL("@baseclass.ShowLogoffTimer");
   oSafeURL.put("time",iTime);
   pega.openUrlInModal.showModalDialog(oSafeUrl,iTime, 210, 620, function(ret){
     if (ret == null || ret == "ok") {
       desktop_restartTimeoutWarningTimer();
     } else {
     pega.u.d.gDirtyOverride = false;
    try {
      application.logOff(true);
    } catch(e) {
      pega.u.d.replace('pyActivity=LogOff&pzPrimaryPageName=pyDisplayHarness', null);
   }
  }
  });
 }



Resolution



This issue is resolved through the following local change: 

When using IE only the following local change can be used to use window.showModalDialog and restore functionality.

Add the following javascript functions to a custom pxSessionTimer:


function desktop_restartTimeoutWarningTimer(){


  if (pega.desktop.TimeoutTime && pega.desktop.TimeoutTime > 0) {
  /* Calculate the time to initial warning in milliseconds*/
  var nTimeoutWarningTime= (pega.desktop.TimeoutTime - pega.desktop.TimeoutWarningWindow) * 60000;

   /* Clear the existing countdown */
   clearTimeout(pega.desktop.TimeoutWarningCountdown);
    if (nTimeoutWarningTime >= 0) {
       pega.desktop.TimeoutWarningCountdown = self.setTimeout("desktop_showTimeoutLogoffDialogFix('"+pega.desktop.TimeoutWarningWindow+"')",nTimeoutWarningTime);
    }
  }
}

function desktop_showTimeoutLogoffDialogFix(strTime) {
   var iTime = parseInt(strTime);
   iTime = iTime * 60000;
   var oSafeURL = new SafeURL("@baseclass.ShowLogoffTimer");
   oSafeURL.put("time",iTime);
   var ret = window.showModalDialog(oSafeURL.toURL(),iTime,"dialogHeight:210px;dialogWidth:620px;help:no;resizable:yes;status:no;");
   if (ret == null || ret == "ok") {
         desktop_restartTimeoutWarningTimer();
   }
   else {
       pega.u.d.gDirtyOverride = false;
       try{
          application.logOff(true);
       }catch(e){
          pega.u.d.replace('pyActivity=LogOff&pzPrimaryPageName=pyDisplayHarness', null);
       }
   }
}



A internal bug item has been added to resolve the usage of the prefered "pega.openUrlInModal.showModalDialog". 

Published January 31, 2016 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us