Question
Rulescube
CA
Last activity: 16 Oct 2018 12:03 EDT
What invokes the pyOnbeforeWindowClose activity
We would like to ensure the user logs off from PRPC upon closing of the browser. When we traced the OOTB Case Manager Portal, we noticed that the pyOnbeforeWindowClose activity was triggered. It appeared that we can include the log off piece into this activity.
We would like to find out the js script or whatever that called this activity. We have some customized portals that somehow no longer fires this activity.
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
Hi Terence,
Thanks for posting your query in the Product support community.
Explanation:
- Currently many OOTB prpc portals upon closing them invoke "pyOnbeforeWindowClose" to release requestor locks , We are extending the same activity to update the presence state of current requestor to disconnected state.
- Upon browser window/tab close, AJAX request to run activity "pyOnbeforeWindowClose" is being fired from “webwb • pzpega_ui_doc_lifecycle • js” which has listener for window unload event.
- Currently in PRPC there are 2 types of portals, framed and frame-less. "pyOnbeforeWindowClose" is invoked for all framed portals during window unload. It is NOT invoked or frame-less because for each user action, complete windows gets unloaded.
Check the attachment for the snippet from “webwb • pzpega_ui_doc_lifecycle • js” from where AJAX request to run activity "pyOnbeforeWindowClose" is fired.
Hope this information might help you to achieve your requirement.
Regards
Mahesh
Rulescube
CA
Mahesh, thank you very much for your response. It is extremely helpful. With respect to your comments on framed and frameless portals, can you please elaborate on the difference between the two? I don't get to see a specific configuration option in the Portal rule form.
Thanks
Terence
Updated: 7 Jul 2017 0:17 EDT
Pegasystems Inc.
US
Terence,
Sample Portals for which activity is not invoked(No Frame/Frameless portals) :
- pyPega7Express(pega express)
- pyCaseWorker(case worker)
Note: The reason why the activity is not invoked for Pega Express and Case Worker portals is because they are no frame/frameless portals.
Sample Portals for which activity is invoked(Framed Portals) :-
- Developer
- pxExpress(Express mode)
- pyCaseManager7
- pyCaseManager
- pyAccessManager(Access Manager)
In case of no frame/ frame less portals upon each user action(ex: click of button) , the complete window gets unloaded and loaded again , So if the activity was invoked unconditionally , then for every user action , harness unload happens and activity is invoked leading to release of locks held by requestor , which shouldn't happen as it's not a browser close, so in JS code a check has be added in 7.1.6 release to avoid invoking the activity in case of no frame portals.
Terence,
Sample Portals for which activity is not invoked(No Frame/Frameless portals) :
- pyPega7Express(pega express)
- pyCaseWorker(case worker)
Note: The reason why the activity is not invoked for Pega Express and Case Worker portals is because they are no frame/frameless portals.
Sample Portals for which activity is invoked(Framed Portals) :-
- Developer
- pxExpress(Express mode)
- pyCaseManager7
- pyCaseManager
- pyAccessManager(Access Manager)
In case of no frame/ frame less portals upon each user action(ex: click of button) , the complete window gets unloaded and loaded again , So if the activity was invoked unconditionally , then for every user action , harness unload happens and activity is invoked leading to release of locks held by requestor , which shouldn't happen as it's not a browser close, so in JS code a check has be added in 7.1.6 release to avoid invoking the activity in case of no frame portals.
- For no frame/frameless portals, activity "pyOnbeforeWindowClose" will be not invoked . For such portals , the mechanism of detecting heartbeat absence will mark the requestor as disconnected. But this would happen after a delay.
- This activity should be invoked for all framed portals ,as the “webwb • pzpega_ui_doc_lifecycle • js” is loaded for all prpc harness.
- If user creates a portal rule with complete custom code , then the “webwb • pzpega_ui_doc_lifecycle • js” may not be included and hence activity will not be fired.
Hope this makes you clear.
Regards
Mahesh
Morgan Stanley
CA
Add a dynamic container in section in the portal. This activity never gets invoked. Traced in Fiddler and tracer. No ajax call traced.Raised an Pega SR-B65422 for this issue. Product version used is 7.1.7. Slight difference in the if block in code posted by Mahesh.
if (pega.u.d.isPortal()) {
if (!pega.u.NavigateTopHandler) {
var F = SafeURL_createFromURL(pega.u.d.url);
F.put("pyActivity", "pyOnbeforeWindowClose");
var B = F.toURL();
var I = pega.desktop.support.getDesktopWindow();
if (!I) {
I = window;
}
I.pega.util.Connect.asyncRequest("GET", B);
}
}
Morgan Stanley
CA
Reproduced the issue in 7.2.2 as well. Just add a Dynamic container in a section. Launch the portal and then close the browser. The activity was not invoked. No logs in tracer or Fiddler.
Morgan Stanley
CA
Mahesh,
Using Dynamic container in a 'multi document' mode invokes the activity while using it in 'single document' mode do not. This test was done using the same portal. How can you explain this?
Pegasystems Inc.
US
Warning!
Doing a logout in pyOnbeforeWindowClose will not always work properly. There is a call to pyDeleteDocumentPg in the same function, harnessOnbeforeUnload, that will end up running last most of the time. Any logoff has to be the last HTTP request to PRPC if the window is closing otherwise a requestor will still be there.
I have tested this an even though the call to pyDeleteDocumentPg is coded first it always runs last. I looked at fiddler and tracer.
We will need to look at this because I believe there are some things we can do here so you could use pyOnbeforeWindowClose to logoff. If we reverse the logic and call pyOnBeforeWindowClose first we can then not call pyDeleteDocumentPg if the portal is closing. That will need some internal discussion though as it could have negative effects if logoff is not called in pyOnBeforeWindowClose when dealing with browser tabs and returning the same session.
--Chris
Virtusa Consulting Services
IN
Hi Chris,
We are going live next month and this issue has been found by our business while doing UAT. They launch their pega app from a different app and once done closes the app by closing browser directly. They don't want to change this behavior hence we need to log off on browser closing.
Any advice on doing so please otherwise our go live will be in danger.
Thanks!
Pegasystems Inc.
IN