Custom Entity Container JavaScript Extension Example #2

Custom Entity Container JavaScript Extension Example #2

Note : this JavaScript is part of a series. Please start with part one,  continue reading here then visit the final example in part three. You can also watch a quick video of the final example on  our YouTube Channel.

Following on from the previous post, we now have a working example that let’s us access an array of data in our inferred entity from the JavaScript extension code we write to manage our Control extension(s). But what about when we want to use this code outside of Debug mode? And why does it only work in Debug mode? What are the additional caveats we are going to find? Let’s make Custom Entity Container JavaScript Extension Example #2!

Debug Mode

The Oracle PolicyAutomation object in your JavaScript  has EnableDebugMode tucked away deep in the interview.js static resource file. This produces the beloved Debug Console window you see when you are working the Debug in your browser or in the embedded browser, which pipes the console output into this dinky pink box:

Custom Entity Container JavaScript Extension Example #2

When working in Debug mode, you have also noticed (and this is not a surprise) that some interesting objects and functions are available that do not show up when the project is deployed. This is not a surprise really. But in our case, we would like to have access to our array of data for our (perhaps twisted and even unprecedented) purposes. So where do we go from here? The answer, as always, turns out to be relatively simple.

The interview object contains a reference to the same array in the form of[1].instances. Note that the number one assumes that you have only two entities, Global and something else. You will have to inspect your code and find out which node you are interested in if you have more. It looks like this in my case.

Custom Entity Container JavaScript Extension Example #2

Once you have that reference, you can do two things easily.

  1. You can figure out the length of the array and use it in your for…each loop
  2. You can select one of the child array called attributes and dig up the information you need to display

So in this new, non-Debug version of the code, you would end up with the following changes compared to the previous post.

Custom Entity Container JavaScript Extension Example #2
  1. In the early part of the script, get a reference to the part of the interview object you need
  2. Use it in a similar way to previously to get the different attribute values you want to display

This code will run even if you are not using the debugger and you have deployed the project to an Interview URL.

Watch Out!

But there is another caveat. The exact index (location) of your entity in the array of entities will change as you compile and deploy your project. So we need a mechanism to make sure we have selected the correct entity and instances.  What today is index 3 might be index 2 tomorrow. Since the entity you are looking for has a unique public name, you might use that to find it. Something like this (based on code taken from

Custom Entity Container JavaScript Extension Example #2

Working through the different nodes until you find the right one, based on the unique name.

Custom Entity Container JavaScript Extension Example #2 Summary

This approach allows us to take the same technique and improve our “Custom Entity Container JavaScript Extension Example #2” to function outside of the Debug window and give it a more robust mechanism for searching for our entity. I would not be surprised if at some point this reference was made easier to access but for now, this seems to do the trick. The documentation is, as ever, available online.

Code Example

As always the code is available for free download from the OPA Hub Shop. Look for Custom Entity Container JavaScript Extension Example #2  in the product list. But we are still not finished, for in part three of this series we will finish off in style by skinning our List of Instances with jsGrid.

Author: Richard Napier

After 8 years in case management and ERP software roles, Richard Napier joined Siebel Systems in 1999 and took up the role of managing the nascent Siebel University in Southern Europe. He subsequently was Director of Business Development and Education for InFact Group (now part of Business & Decisions) for 8 years. He now runs Intelligent Advisor IT Consulting OÜ. Owner of, he also is Co-Founder of the Siebel Hub.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Intelligent Advisor IT Consulting Serving Customers Worldwide
Hide picture