We have a set of cases tagged together, where users were entering huge volumes of text.
Users want the ability to save draft versions during the case life cycle and want to ability to access and view saved versions in a popup.
There is a navigation in the popup, where users would like to navigate between set of cases that were tagged.
Since we are launching popup, user is free to perform any action in parent window, including save or submit.
Once commit action is performed in parent window, and user is trying navigate in child window, user is seeing error "This action is not allowed as it is outside the current transaction."
Background on pzTransactionId property and how PRPC uses it -
PRPC maintains a Transaction ID for every POST Request and validate whether request is valid or not.
Transaction ID can be located @pxRequestor.pxClientExchange .
When a window is loaded, there are few property available at window level pega.u.d.url and document.forms.action which contains this parameter transaction id.
Whenever Browser / Client sends an post request, it contains pzTransactionId parameter. PRPC validates client pzTransactionId value with Server pzTransactionId value. If both are different PRPC throws error message something like "posted transaction id '<Client value>921a0b589d6e18558407416a5182b15c' for frame 'pyWorkPage' DOES NOT match record '<Server value>'"
After POST request response, PRPC sends the updated pzTransactionId value to client, so that it would become pzTransactionId value for next request.
When save or commit operation is performed from parent window, which effected the transaction id, parent window is refreshed to capture new transaction id value, but not the popup window.
Hence subsequent call from popup window, which still has the old transaction id lead to "This action is not allowed as it is outside the current transaction."
Place the below script in userworkform or in JS file and make it available to window in question.
For every click on popup window I configured to call below handleDraftPopupStaleTransactionIssue function as first action. (Note: this has to be a first action)
var newurl = SafeURL_createFromURL(pega.u.d.url);
pega.u.d.url = newurl.toURL();
var url = document.forms.action;
var formURL = SafeURL_createFromURL(url);
In my case, no write actions are allowed from popup window, hence I am calling this script only from popup window.
You need to call this script this function as first action, where ever you expect to see stale transaction.
I have a Perform harness configured as a Work area, and I was trying to launch another OOTB harness as a Pop-up window from a Link's Action set. In the harness action set I specified an activity to open a Pega KM article. But then I noticed when I tried to launch the harness again, that I got error: "This action is not allowed as it is outside the current transaction".
So, I added the JS function you provided as a first action set (before the harness one) and that fixed the issue 🙂