Oracle Policy Automation – JavaScript Custom Options

Following on from the occasional series of posts that has dealt with  Oracle Policy Automation JavaScript Custom Labels and Oracle Policy Automation JavaScript Custom Search extensions, this short post is going to demonstrate how to use the custom Options extension to build an Oracle Policy Automation – JavaScript Custom Options example. The scenario is very simple, and can mostly be achieved using non-JavaScript functionality but the goal is to showcase the capability. You will need to imagine your own business requirement.

Let’s get started. In a simple Oracle Policy Automation Project I have three attributes : the Country, the Town and the Town Level. In each Country, there are a certain number of Towns. These can be considered as a dynamic list for the purposes of our demonstration. They will be stored in an Array of Objects. They could, naturally, be obtained from a REST call to some service or other, much like the example of Search Extension. For our purposes we will have only four towns per country. Each town has a level, which corresponds to its population size.

When the user selects a Country and Town Level, we will display in a Custom Options list, the Towns that have the same Town Level or higher. So if you choose level three, we would like to see towns of levels one, two and three. If we choose level two, we would like to see levels one and two in our Oracle Policy Automation – JavaScript Custom Options list. We wish to display them as radio buttons.

Oracle Policy Automation – JavaScript Custom Options Example

How can we achieve this goal:  here is the example in more detail.

The User Interface is prepared according to the following screenshots:

Oracle Policy Automation - JavaScript Custom Options - Setup CountryThe above shows the first Screen.

Oracle Policy Automation - JavaScript Custom Options - Setup Options Extension

The second Screen displays the future dynamic Options. Note how it is a simple Textbox.

Oracle Policy Automation - JavaScript Custom Options - Code Introduction

In the above image, the basic setup is performed. Values of the Country and Town Level are acquired. An empty Array of towns is created.

Oracle Policy Automation - JavaScript Custom Options - Code Array Creation

The second part of the code is too long to reproduce here, but the above image will give you the idea. According to the Country, the array of Town objects is built. Note the text and value properties which are required, and I have added a level property. I have also, of course, created an alternative set of towns for Ireland (but I won’t show it to save space). Now I will filter the array based on the town level chosen:

Oracle Policy Automation - JavaScript Custom Options - Code Return Array Filtered

In this final screenshot, you can see the filter is based on the level and the filtered array is passed out. In addition I have specified the display as radio buttons.

Oracle Policy Automation – JavaScript Custom Options Result

Executing the code in the Project we can see the following when we select the country as Ireland, and the town level as 2, for example:

Oracle Policy Automation - JavaScript Custom Options - Result Example One

In the same vein, when France is chosen, and town level 1, this is the result:

Oracle Policy Automation - JavaScript Custom Options - Result Example Two

Have a nice day! If you would like a copy of the example code and Oracle Policy Automation – JavaScript Custom Options Project, just leave a comment to that effect. As always the official documentation can be found on the Oracle website.