Policy Automation for B2C Service

Get Involved. Join the Conversation.

Topic

    albert hua
    After embedding the interview in an application, how to...Answered
    Topic posted May 13, 2018 by albert huaRed Ribbon: 250+ Points 
    68 Views, 6 Comments
    Title:
    After embedding the interview in an application, how to enable the Submit button to redirect to...
    Content:

    Hi there,

    We have created an interview and successfully embedded into another application:

    <script src="https://murdoch-opa--tst1.custhelp.com/web-determinations/staticresource/interviews.js"></script>
    <div style="display: inline-block; width:100%">
        <div id="future_learn" style="width: 100%; display: block; margin-left: auto; margin-right:auto; float: left"></div>
    </div>
    <script>
        var el = document.getElementById("future_learn");
        var webDeterminationsUrl = "https://murdoch-opa--tst1.custhelp.com/web-determinations";
        var deploymentName = "FutureLearn_tst";
        OraclePolicyAutomationEmbedded.StartInterview(el, webDeterminationsUrl, deploymentName );
    </script>

    The question is how to set a redirect when user finish the interview and click the Submit button? See image below. Currently it just stays at the page and going nowhere.

    Any advice?

    Many thanks,

    Albert

     

    Version:
    2017
    Image:

    Best Comment

    Brad Tuckett

    The onNavigate handler is a function - so you need pass an object, not a string.  There's an example further on in that documentation topic called "Show me an example of the code to embed multiple interviews on the same web page" that shows a simple onNavigate function:

    //This method is passed as the "onNavigate" parameter to handle exit/redirect../save and redirect
    function doExit(url){
        //navigate current page to specified url
        window.location = url;
    }
    

    you then just pass the function name as the onNavigate object:

    OraclePolicyAutomationEmbedded.StartInterview(el, webDeterminationsUrl, deploymentName, undefined, undefined, undefined, undefined, undefined, doExit);
    

     

    Comment

     

    • Brad Tuckett

      Firstly, this screen needs to be set to "Submit and Redirect" during policy authoring.

      Then you need to provide a handler for the onNavigate event.  This is one of the optional parameters to the StartInterview method.

    • albert hua

      Thanks Brad.

      Our sys admin has enabled the "submit and redirect" button. See below.

      But unfortunately, when I incorporate this onNavigate to StartInterview(), the error shows: Policy model "FutureLearn_tst" does not support locale: "Submit"

      Any idea?
       
      Cheers,
      Albert
       
      <script>
          var el = document.getElementById("future_learn");
          var webDeterminationsUrl = "https://murdoch-opa--tst1.custhelp.com/web-determinations";
          var deploymentName = "FutureLearn_tst";
          var onNavigate = "Submit";
          OraclePolicyAutomationEmbedded.StartInterview(el, webDeterminationsUrl, deploymentName, onNavigate);
      </script>
    • Brad Tuckett

      You need to provide the missing optional parameters prior to onNavigate - you have only provided the first optional parameter (locale).

      Try:

      OraclePolicyAutomationEmbedded.StartInterview(el, webDeterminationsUrl, deploymentName, undefined, undefined, undefined, undefined, undefined, onNavigate);
      

       

    • albert hua

      Aha...Thanks Brad. This fixed the "not supported locale" error.

      But unfortunately, our last interview page where the Submit is still not performing any redirect. It shows a "waiting for response" message and then just stays at the same page. See attached.

      Is the onNavigate handler I assigned is not correct? The interview itself running as standalone is redirecting fine, but when embedded into the application, it doesn't do the redirect anymore.

      Cheers,

      Albert

      var onNavigate = "Submit";
      OraclePolicyAutomationEmbedded.StartInterview(el, webDeterminationsUrl, deploymentName, undefined, undefined, undefined, undefined, undefined, onNavigate);
    • Brad Tuckett

      The onNavigate handler is a function - so you need pass an object, not a string.  There's an example further on in that documentation topic called "Show me an example of the code to embed multiple interviews on the same web page" that shows a simple onNavigate function:

      //This method is passed as the "onNavigate" parameter to handle exit/redirect../save and redirect
      function doExit(url){
          //navigate current page to specified url
          window.location = url;
      }
      

      you then just pass the function name as the onNavigate object:

      OraclePolicyAutomationEmbedded.StartInterview(el, webDeterminationsUrl, deploymentName, undefined, undefined, undefined, undefined, undefined, doExit);
      

       

    • albert hua

      Awesome Brad. Thank you a lot for your patience and knowledge. I was newly on board for the RightNow stuff, hence a lot to learn. 

      Thanks again and you have a lovely day!

      Albert