Support Article
In Pega Mashup, gadget is not loading as expected for first time
SA-42153
Summary
User has configured two gadgets, one to display work items and the other to create work action. When user is accessing the mashup page in an external application, one of the gadgets is loading as expected. Status fail message is thrown for the other gadget.
Error Messages
status fail message:
Steps to Reproduce
1. Configure Pega Mashup with two gadgets with data-pega-action-param-parameters configured as authentication parameters.
For instance,
<div id="PegaGadgetA" style="display:none;" data-pega-gadgetname ='PWGadgetA'
data-pega-action ='createNewWork'
data-pega-action-param-classname ='OES1W1-myApp123-Work-CSR'
data-pega-action-param-flowname ='pyStartCase'
data-pega-action-param-model =''
data-pega-isdeferloaded ='false'
data-pega-applicationname ='MyApp123'
data-pega-threadname ='STANDARD'
data-pega-systemid ='pega'
data-pega-resizetype ='stretch'
data-pega-url ='http://hostname:8282/prweb/PRServlet'
data-pega-action-param-parameters={UserIdentifier:"Admin@myapp123",Password:"cnVsZXM%3D"}> </div>
<div id="PegaGadgetB"
style="overflow:auto"
data-pega-gadgetname="PWGadgetB"
data-pega-action ='display'
data-pega-action-param-classname ='OES1W1-myApp123-Work-CSR'
data-pega-action-param-harnessname ='MashUpHarness'
data-pega-action-param-model =''
data-pega-isdeferloaded ='false'
data-pega-applicationname ='MyApp123'
data-pega-threadname ='STANDARD'
data-pega-systemid ='pega'
data-pega-resizetype ='stretch'
data-pega-url ='http://hostname:8282/prweb/PRServlet'
data-pega-action-param-parameters={UserIdentifier:"Admin@myapp123",Password:"cnVsZXM%3D"}>
</div>
Root Cause
Reported behavior is because of the race condition between two network calls.
Two requests are called in parallel with pre authentication cookie. Server will start executing the first request and requestor will be authenticated. Server will start executing second request and it sees request has pre-authentication cookie even after user is authenticated in the first request and it throws an error.
Resolution
Perform the below steps as local-change:
- Defer load one gadget by adding "data-pega-isdeferloaded ='true'" attribute.
- Add onload event for the other gadget by adding "data-pega-event-onload = 'gadgetLoadCallback'" attribute.
- Add script to load deferloaded gadget once the other gadget is loaded as below:
function gadgetLoadCallback() {
pega.web.api.doAction("<Second Gadget Name>", "load");
}
Published August 9, 2017 - 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.