Support Article
getGadgetData always returns undefined when using Mashup
SA-44737
Summary
getGadgetData always returns 'undefined'. Mashup is used to retrieve data from DataField in PRPC content using getGadgetData.
Code examples,
var firstName = pega.web.api.doAction("GCSTestDataBind", "getGadgetData", "[gadget/GCSTestDataBind/OperatorID.pyFirstName]");
var createOpName = pega.web.api.doAction("GCSTestDataBind", "getGadgetData", "[gadget/GCSTestDataBind/.pxCreateOpName]");
Syntax is as defined according to the PDN article: https://pdn.pega.com/pega-web-mashup-data-binding-syntax/pega-web-mashup-data-binding-syntax
Application record has the correct host names set in Mashup security section.
Error Messages
Not Applicable
Steps to Reproduce
- Configure the Simple Gadget: CreatNewWork - PegaSample-Task - BasicProcess
- Set the Data Fields present in New harness: OperatorID.pyFirstName
- Set the Data Fields present in Resolve Flow Action: .pxCreateOpName
- Use Mashup to retrieve data from DataField in PRPC content using getGadgetData
Root Cause
The PDN documentation listed above is incorrect.
Resolution
The use of getGadgetData requires the usage of a callback function:
pega.web.api.doAction("GADGETNAME", "getGadgetData", "[PropertyRefence]" {callback:function(){},scope:scope});
For example,
function getTheGadgetData(){
pega.web.api.doAction("GCSTestDataBind", "getGadgetData", "OperatorID.pyFirstName", {callback:callBackForFirstname});
}
function callBackForFirstname(rtnValue){
alert("return value: " + rtnValue);
}
Additionally, 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.
Published October 25, 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.