Posted: 5 Jul 2017 11:48 EDT 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.
Thanks for posting your query in the Product support community.
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.
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.
Sample Portals for which activity is not invoked(No Frame/Frameless portals) :
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) :-
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.
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.
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.
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.
Thank you for posting your query on PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write a Post button that’s available on the top right pane of this page. Once created, please reply back here with the URL of the new post.
We have also sent you a private message opening up a communication channel in case you have any further questions.