Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

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

Updated on February 7, 2022

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>
    For example: 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>
  • Previous topic Cannot load the same mashup again based on conditions
  • Next topic Cannot load a mashup from a non-default access group

Have a question? Get answers now.

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

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us