Support Article

CloseAllDocument JavaScript is unable to close all tabs

SA-2291

Summary



User has a portal which loads according to a Company account selected in the portal. CloseAllDocuments API is used to close all the tabs on switching accounts in the portal, before the content of other account loads up. This however, leaves one of the previous tabs open in Pega 7.1.6.

Error Messages



Not Applicable.

Steps to Reproduce



1. Create a portal with a custom harness.
2. Include a navigation rule which is used to switch between company accounts.
3. On click of the navigation call the "CloseAllDocuments" api from Pega.Desktop and pass the event object to it.
4. Load another JavaScript to the harness which creates a "Account Dashboard" tab, using the createnewworl API, each time the harness is loaded.
5. Run the portal and observe a dashboard being created on load of harness.
6. Open other tabs configured in the portal.
7. Switch the account using navigation rule.
8. Observe the tabs from previous account that still remains.


Root Cause



The "CloseAllDocuments" was taking time to complete, which caused either the page to refresh earlier and since DOM was replaced, it could never complete processing.


Resolution



Perform the following local-change steps:

1.Remove the "CloseAllDocuments" from the navigation rule.
2. Add it to the onload of harness, so that it closes the tabs before creating the new one.

This also ensures that all work has been completed and dirty fields for other tabs, have also been overridden, before this API is called.
Suggest Edit

Published January 31, 2016 - Updated October 8, 2020

Have a question? Get answers now.

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