Support Article
Mashup: getGadgetData, setGadgetData, getGadgetInfo not working
Summary
Using Pega Mashup and getGadgetData or SetGadgetData not working.
Error Messages
Not Applicable
Steps to Reproduce
- Create a harness containing a property (for example, City).
- Add the City property as Data Field in the Harness.
- Create one html page as shown in the html.
- Include the Page harness in the above html using Pega Mashup.
- Try to copy the Harness property value to the field in the host page (html), not working.
- Try to set the value to a property in the harness, but not working.
Root Cause
The documentation here https://pdn.pega.com/pega-web-mashup-page-javascript-actions/pega-web-mashup-page-javascript-actions is out dated.
The API for getGadgetData, setGadgetData and getGadgetInfo has changed as of Pega 7.2.1 and the documentation changes are not yet complete on PDN.
Resolution
Similar to https://pdn.pega.com/support-articles/getgadgetdata-always-returns-undefined-when-using-mashup
Pega now uses Window post messages for communication from top level application to PRPC. The nature of this change requires callback functions.
pega.web.api.doAction("GADGETNAME", "getGadgetData", "[pyWorkpage.Property]", {callback:function(){},scope:scope});
pega.web.api.doAction("GADGETNAME", "setGadgetData", "[pyWorkpage.Property]", "value",{callback:function(){},scope:scope});
pega.web.api.doAction("GADGETNAME", "getGadgetInfo", {callback:function(){},scope:scope});
Example: getGadgetData:
function getTheGadgetData(){
pega.web.api.doAction("GCSTestDataBind", "getGadgetData", "OperatorID.pyFirstName", {callback:callBackForFirstname});
}
function callBackForFirstname(rtnValue)
{
alert("return value: " + rtnValue);
}
DataField not used anymore:
Also as of Pega 7.2.1 DataField controls are no longer used for getGadgetData. Instead use a simple hidden input element using the control "Hidden Input".
Application Integration and Security:
On the application record there is an Integration and Security tab that contains a “Mashup Security” section. This must contains the host site that is including the Mashup content.
Published July 23, 2018 - Updated February 4, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.