LinkedIn
Copied!

Table of Contents

Cannot load a mashup asynchronously based on an event or a flag

Version:

Only available versions of this content are shown in the dropdown

Ensure that you can successfully load a mashup asynchronously based on an event or a flag.

Condition

The mashup does not load when you try to load the mashup asynchronously based on an event, or depending on a flag.

Solution

  1. Put a debugger in the _initAllPegaObjects method defined in PegaCompositeGadgetMgr.js.

  2. If the debugger does not pause, you can explicitly invoke the method when you insert the mashup <div> snippet into the HTML. Use the following _initAllPegaObjects method definition:

    function _initAllPegaObjects() {
    
          if(pega && pega.web && pega.web.isWebMashup){
    
            if (!bPegaIacInitialOnLoad) {
    
              pega.web.mgr._updateGadgets();
    
              return;
    
            }
    
            bPegaIacInitialOnLoad = false;
    
            pega.web.mgr._initLog();
    
            pega.web.mgr._logMsg("info", "", "Manager", "Started Pega IAC manager initialization.");
    
            /*BUG-270078 Logic to detect cookie enabled or not*/
    
            pega.web.mgr._ut._setCookie("PegaIAC", "IACtest", 1);
    
            if (pega.web.mgr._ut._readCookie("PegaIAC") != "IACtest") {
    
              pega.web.mgr.cookiesDisabled = true;                                                                     // cookies are disabled
    
              pega.web.mgr._logMsg("error", "", "Manager", "error: Browser cookies must be enabled for Pega IAC to function.");
    
            }
    
            pega.ctx.bEncryptURLs = false;
    
            pega.web.mgr._initGadgets(window);
    
            bPegaIacGadgetsInitialized = true;
    
            return;
    
          }
    
    <script src ='http://sample.pega.com/prweb?pyActivity=pzIncludeMashupScripts'></script>
    The following sample code inserts the mashup <div> snippet into the host page dynamically and explicitly invokes the _initAllPegaObjects method to initialize the mashup gadgets:
    <script> 
    
    function loadMashup() {
    
        var snippetDiv = document.createElement("div");
    
        snippetDiv.setAttribute("data-pega-gadgetname", "PegaGadget");
    
        snippetDiv.setAttribute("data-pega-action", "createNewWork");
    
        snippetDiv.setAttribute("data-pega-action-param-classname", "OES023-Myapplication-Work-Interaction");
    
        snippetDiv.setAttribute("data-pega-action-param-flowname", "pyStartCase");
    
        snippetDiv.setAttribute("data-pega-isdeferloaded", "false");
    
        snippetDiv.setAttribute("data-pega-threadname", "MashupThread");
    
        snippetDiv.setAttribute("data-pega-applicationname", "Myapplication");
    
        snippetDiv.setAttribute("data-pega-resizetype", "stretch");
    
        snippetDiv.setAttribute("data-pega-url", "http://sample.pega.com/prweb");
    
        snippetDiv.setAttribute("data-pega-action-param-parameters", JSON.stringify({
    
             "UserIndentifier": "cherj",
    
             "Password": "xykdhjd"
    
         }) + "");
    
    
        document.getElementById("wrapperDiv").appendChild(snippetDiv);
    
    
        //trigger mashup loading explicitly in asyn case
    
        _initAllPegaObjects();
    
    } 
    
    </script
    
    
    <div id="wrapperDiv"></div>
    
    <button onclick="loadMashup">Load Mashup</button>
Did you find this content helpful?

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.