Not able to pass dynamic parameter in mashup code

Hi Team

We are using mashup code to create a case . We want to pass few parameters to the mashup code and get those parameters to be used in the work object what we are creating post authentication.

We have used below code to pass 3 different parameters namely “UserIdentifier” ,“AppContext” and “Originator”

Only “User Identifier” parameter is getting passed as its a hard coded value , other 2 parameters which are dynamically set are not getting passed , even though these 2 values are appearing in alert message.

If some one has already faced such issues , please let us know what are the options available to pass a dynamic value inside mashup code to be accessed by the case which user will be creating. Providing an example code snippet rather than Pega community help links are much appreciated.

<script src ='https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'></script>

<style>  

        Iframe {

        width:100% !important;

                }

</style>

<body>

<div id="PegaGadget#1"

data-pega-encrypted ='true' 

data-pega-encrypted-hash = 'pzuiactionzzz=CXtpbn01cGZFd3NSV1d0RWYwd0Npa2dSY3ZaWW40SFd2QWd0bWpMUzRqWis4ZnQ1cGhiZVZPVkljSGl4ZXM2TWJ1c1dNcCtKVC96dUNDV3JGeGZOV0dDOTQ0NjhUNWs1d3RnQ0RaU3VxZ21Sb2haN0hKWWpQcmRsQ2ludk1nQXFiOEU2YXJZSElMQU5JUGR6MFE3ZDkwcWVZTXRMTXhoczZtVE0yVHZRNlMydHdGdTNaajBnVVpIQ2kvQy9lRFNJZjJjZ0VmU3BWK1FEVnFwU1RRMERZdmk1Z3BLWFNoUThCY2preWQwZkE1eHhEQTVzTFBpeEovOGlzUFFUK2hZcjFESzVDNkxWUVAyTi9sd254MTB5dlAvVEhlc3cxTGc0MW1OaUlRWDFYZTdVcUFDMD0%3D*' 

data-pega-gadgetname ='PegaGadget' 

data-pega-action ='createNewWork' 

data-pega-action-param-classname ='PegaCA-Work-GeneralRequest' 

data-pega-action-param-flowname ='pyStartCase' 

data-pega-isdeferloaded ='false' 

data-pega-applicationname ='xxxxxxxxxxxxxxxxxxxxx' 

data-pega-threadname ='CreateGSR' 

data-pega-resizetype ='stretch' 

data-pega-url ='https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' >

</div>

<!-- ---------------------- End Pega content ---------------------- -->

</body>

<script>

    

    var AppContext='{AppContext:"<%=tools.findPage("Application").getProperty("pyLabel")%>"}' ;

    var Originator= '{Originator:"<%=tools.findPage("pxRequestor").getProperty("pyUserIdentifier")%>" }';

    var UserIdentifier= '{UserIdentifier:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}';

    var gadget = document.getElementById("PegaGadget#1");

    gadget.setAttribute("data-pega-action-param-parameters",AppContext);

    gadget.setAttribute("data-pega-action-param-parameters",Originator);

    gadget.setAttribute("data-pega-action-param-parameters",UserIdentifier);

    

</script>

Hi

This issue got resolved after using the below code snippet.

<script>  

var params = {};

params.UserIdentifier="xxxxxxxxxxxxxxxxxxxxxxx";

params.Originator='<%=tools.findPage("pxRequestor").getProperty(".pyUserIdentifier").getStringValue()%>';

params.AppContext= '<%=tools.findPage("Application").getProperty(".pyLabel").getStringValue()%>';  

document.querySelector("div[data-pega-gadgetname ='PegaGadget']").setAttribute("data-pega-action-param-parameters",JSON.stringify(params)+"");  

  </script>

Thanks sanjeeb tripathy for sharing your resolution! I have marked it as such to help others who may have the same question!

Marissa | Senior Moderator | Pega Collaboration Center