Policy Automation for B2C Service

Get Involved. Join the Conversation.


    Javascript API and OPA
    Topic posted August 3, 2015 by NisarBronze Crown: 15,000+ Points, last edited August 3, 2015 
    655 Views, 8 Comments
    Javascript API and OPA

    I'm accessing an OPA interview inside the Service Cloud (Not via the browser control/CP page). In one of the scenarios, I'm required to load the Javascript API. But it doesn't seem to be working and I'm getting the following error whenever the following line is executed

    var inc = window.external.Incident;

    The error being thrown is

    TypeError: Unable to get property "Incident" of undefined or null reference

    Does this mean I can't use Javascript API inside OPA interviews?

    EDIT: My bad! It's not via the browser control, but within the Service Cloud CX itself.




    • Scott Berry

      Just to clarify, do you mean you have embedded the interview on a Customer Portal page via the OPA Widget, or the interview is running within the ServiceCloud CX? In the Customer Portal the Interview is rendered inside an iframe, and because of this the iframe javascript does not have permission to reach outside of the iframe to the parent window. You may however use javascript on the parent page which sets a controls value inside the Interview with something like:

    • Davin Fifield

      A couple of questions.

      1. It sounds like you are using the Browser Control instead of the built in OPA control for Agent Desktop. Can I ask why?

      2. Since you are using the Browser Control you can provide the incident ID via the supported command-line parameters. In combination with the Delay Load option this should allow you to do what you need.

    • Nisar

      Hi Scott and Davin,

      The interview is running within the ServiceCloud CX and not a CP page. At the end of the interview, we are using the "Submit and Redirect" option and inside the redirected page, Javascript API code is set to run.

      I'm assuming that the moment the interview ends and the page redirection takes place, it opens the page within the browser control. And this is where I intend to use the Javascript API

    • Davin Fifield

      What is the URL of the redirected page?


      We might need to get someone more experienced with the Agent Desktop to help us understand why you can't successfully use the Javascript API - that isn't an OPA feature.

    • Nisar

      Hi Davin,

      The URL points to a CP page.

      EDIT: I can't seem to copy-paste the direct HTML of the page, so attaching the same

      50327opa.html (431 Bytes)
    • Davin Fifield

      What do you want to do exactly with the Javascript API. Set the incident ID to something? Are you in the incident workspace?


      The best way to create incidents with OPA inside Agent Desktop is to use the Policy Automation control instead of the Browser Control, and use the mapping in Oracle Policy Modeling to create the incident. This will make sure the incident ID of the incident workspace is set when the interview completes.



    • Nisar

      I probably should have started with the use case scenario. Sorry about that. So here goes:

      • In the Agent Console, the OPA interview (which is a part of the Incident Workspace) starts
      • At the end of the interview, the page is redirected to, let's say, /app/myOPA page.
      • Inside myOPA page, my goal is to use the Javascript API and set a "Yes/No" field on the Incident Workspace. Since I can't touch the workspace fields via the OPA control, I intend to the the JS API to do the same.

      Is this approach right?

    • Davin Fifield

      There is a much easier way, which is simply to drop an OPA control onto your Incident workspace, and use the Mapping Settings on the Data tab in Oracle Policy Modeling to choose options along these lines:

      In Who is this interview for? choose Contact centre staff (Account)

      In At start of interview choose Load a particular: Incident

      In At end of interview choose Update Incident

      This approach requires you to have Single-Sign On enabled between your RightNow and OPA sites (which is done by default if they were provisioned together), and to be licensed for the OPA Agent Cloud Service.