Welcome to the OPA Hub!

Category Archives: featured

RuleScript Part 1 : What, Why, Where

RuleScript Part 1 : What, Why, Where

I hope you all enjoyed the holiday season. Stepping lightly into 2019, we begin with a series on RuleScript. For a long time I have had an article on the tip of my tongue, and it just needed an example to round it out. So this series has now finally seen the light of day. Before we begin the actual work let us set the stage.

What is RuleScript?

RuleScript is an experimental feature that is not enabled in Oracle Policy Modeling by default. You must request access from Oracle Support.

RuleScript is derived from Rhino, an open source implementation of JavaScript in Java. An implementation of what now? To put it simply, you are going to be able to write JavaScript, that will be executed by a Java engine. Not by your Browser. If you came from Siebel CRM, you will be familiar with eScript – basically a JavaScript derivative that runs on the Server, not on the Client browser. Well, it’s kind of the same deal here : your code will not run in the Browser JavaScript engine, but on the server-side Java engine.

Why RuleScript?

There may be times where you are implementing non-business algorithms that are better placed out of the view of the non-technical people in the team. RuleScript can access Attributes, Entities and everything you know and love about Oracle Policy Automation. Your RuleScript can update other attributes and read values as if it was written in Word or Excel. But it is written somewhere else, out of the way of the policy authors. They benefit from what you have done without getting bogged down in it.

It uses JavaScript (or rather ECMA Script) and therefore it is easy for many developers to leverage existing code. It is also possible to achieve things you cannot easily do in standard Oracle Policy Automation rules.

Why Not RuleScript?

This is an experimental feature. It may disappear tomorrow. It may radically change. It may make upgrading harder.

Where is RuleScript?

You write the rules in your Project, just like anything else. Astute readers will see there is another button in this Project in the Rules tab:

RuleScript Button

If you cannot see the button, as described above, get in touch with Oracle Support. Be ready to explain why you need it, and review the example use cases using the URL link above to see if you are on the right track.

How do I use RuleScript?

Well, since this is JavaScript you write in whatever text editor you want. There are a couple of things you need to know before starting.

  • All RuleScripts need a header to be completed. In this example, a brand new file has been added:

Blank RuleScript Header

Notice the last commented line

// RuleScript() <- ()

This cannot be removed (otherwise your Script is no longer a RuleScript) and must be completed for your code to actually work. You must complete both the right hand and left hand side of the expression. Here is an example:

Edited RuleScript Header

You can read this line :

// RuleScript(theresults,resultstep,totaltime,resultstepnumber) <- (origin,destination, thestations,thechildstations,childstation_cost_minutes,child_station,station)

as “The following RuleScript will need to read the attributes and relationships on the right, and write to the stuff on the left”. This tells you two important things :

  • The attributes, entities and relationships must exist, and have names associated with them, before you can write RuleScript with them.
  • Failure to add all the attributes and so on to the list, causes an error with a remark like “Not authorised to access attribute name

There are several other things that you need to know about the RuleScript experience :

Debugging. You can use console.log (but not alert) to push messages to the console. But this is not the Browser console (in fact they will not show up there, as they are not executed in the Browser). Rather it is in the Data tab of the Debugger (notice the messages at the bottom of the window):

Debugger in RuleScript

Editing. The attributes and other elements of your Project that appear in your RuleScript files can be traced in the usual way, and show up when you right-click the attribute for example in the Modeling interface:

Tracking in RuleScript

RuleScript File Structure : You probably noticed in the previous screenshot, that file takes the form of a function. The function can be called anything you like, because you will never actually call that function yourself. It will be called as needed by the determination engine. The rules you define in the RuleScript file can interact with other rules in Word or Excel and can be debugged and watched in the same way as usual. If you have several RuleScript files in the same Project, they essentially are all in the same JavaScript namespace, so functions in a given file can be accessed from another.

Functions: Your RuleScript file can also contain standard JavaScript functions that you create to modularize your code.

The Scenario for Today

In this series, we are going to implement something different than a traditional rule, in order to show the concepts and also the differences with the Rule authoring you already know. We are going to implement an algorithm in RuleScript and use it in our Project. This is called Dijkstra’s algorithm and is in my opinion relevant today, since it deals with networks and nodes and might well come in handy in your daily life.

Read on into part two for more information about the Project and the rather cool idea (in my opinion) behind it all…

Extension Code Generators for JavaScript

Extension Code Generators for JavaScript

Over on my other home (https://siebelhub.com) we use and promote the use of Code Generators : because most of the JavaScript people need to create is in fact very structured, because of the underlying extension architecture. You don’t write just any code, you write code the way you have to write it. So how to write Extension Code?

[Update 1 November 2018 : I added fullCustomInput as an option. I also added more explicit logging – so if you use multiple files you can see which is doing what. I also tidied up a few things]

It struck me the other day that this is equally true now for Oracle Policy Modeling – JavaScript extensions have a very well defined structure, and as I said above : you don’t write just any code – you write it the way you have to write it, in order to fit into the underlying architecture of our beloved interview.js.

Since I find myself often repeating the same JavaScript task over and over again – for example I need to create 2 custom Labels for 2 different projects or customers – I do a lot of cutting and pasting. But that often goes wrong as I forget I’ve renamed something or changed a variable somewhere.

So I decided to create a Code Generator – a sort of tool to create templates of code that I can use to create new files. And I decided to use Oracle Policy Automation for the job. Here is the sort of thing I am talking about:

Extension Code

By answering a few questions about the code you want to write, the Project generates a template for you to copy and paste into a new Text File and there you have your code to start writing something interesting. There is a Copy to Clipboard button at the bottom of the code.

In the end, I decided to add a few things to the examples to act as learning tools:

  1. The Input Control has Validate and Update options that help understand the way these Keys actually are supposed to work. Validate throws an error message to the user if the text entered does not match a specific validation rule.
  2. The Update Key shows how update is fired whenever anything on the Screen is updated. Useful for updating your Control in response to other activity on the Screen. As an example, the color of the Input changes each time Update is fired.

The Extension Code Generator also includes the custom Search as templates with the following options:

  1. Search lets you choose from a series of standard searches (Airlines, Railways Stations, etc) as well as allowing you to configure your own REST call and lets you add any Headers you need to make your call.

Here is a video that will hopefully shed some more light on what this Project does (or tries to do)!

This seemed like a fun thing to do in Oracle Policy Automation – if you would like a copy of the (18C) project then please leave a comment and I will tell you all about it’s foibles :).

Oracle Policy Automation and Siebel Innovation Pack 16 #1

Oracle Policy Automation and Siebel Innovation Pack 16 #1

Oracle Policy Automation and Siebel Innovation Pack 16 : Tutorial Part OneFor some considerable time now, the good people at Oracle have made available a White Paper describing an alternative integration to Oracle Policy Automation and Siebel Innovation Pack 16 integration (as opposed to the Siebel Innovation Pack 15 approach involving a good deal of HTML and so forth, and not supporting some of the new screen layout features and dynamic elements of Oracle Policy Automation).

The white paper is clear enough on the concepts, and some of the screenshots are excellent 😉 but I am often asked about the details of the setup and implementation. In fact it is something I have to do quite often anyway. So I thought I would publish here some content that shows how Oracle Policy Automation and Siebel Innovation Pack 16 can work together.

This content is obviously a mixture of technical and functional, and by definition quite “Siebel-oriented” but I figured it would be of interest here as well, since we all might find ourselves in projects where the two behemoths meet. And I suppose that even someone who just wants to figure out how Oracle Policy Automation connects to “something” might find it interesting as well.

A word of warning : these videos were recorded “live” without editing – or at least without much editing – so there are “troubleshooting” sequences where I do something wrong and then go off and fix it : I figure that keeping that stuff in makes for a bit of “reality TV” so you can maybe gain time yourselves when you get into similar problems. Oracle Policy Automation and Siebel Innovation Pack 16 integration sometimes takes a bit of getting used to.

Finally, in case you were wondering, this is also the foundation for the Oracle Policy Automation and Siebel 16 Workshop that I run from time to time. So, to keep the post from becoming too long, I am going to publish this in several parts. The first part (this post) looks at the various options, the different functional scenarios and the technical approaches that we might encounter in Oracle Policy Automation and Siebel 16 environments. The next post will continue the process.

Welcome to the Videos

What will you need : an Introduction and some Prerequisites

Getting Oracle Policy Automation and Siebel 16 Connected : Part One – Design Time


In the next post in a couple of days, you will continue to learn about the Connection and test the first two operations using SOAP UI, before you move on to the core of the integration.

Guest Post : The Lazy Expert – Using Oracle Policy Automation Public Cloud with Oracle Service Cloud

Using Oracle Policy Automation Public Cloud with Oracle Service Cloud


We are continuing our Lazy Expert series of posts, with an explanation of how OPA Public Cloud, and the rulebases deployed there, can be used within the Oracle Service Cloud application. In case you have missed out on our first part of this series, you can find it here. With the right Nudge, our Lazy Expert is not so lazy after all.

One of the earliest pre-built connectors for OPA comes from the Oracle Service Cloud Service, to connect with an Oracle Policy Automation Public Cloud Instance. Since then, we have seen multiple releases of this connector and each subsequent release improves the functionality available with the OPA Public Cloud Service, as well as how it is used together with the Oracle Service Cloud Service. For the rest of this content, we will be referring to these applications as OPA Cloud and Service Cloud respectively to gain a few centimeters of white space.

OPA Runtime Nudge (Trigger) Possible Scale of Invocations / Volume Typical Application / Solution Architecture Use by Service Cloud
Policy Hub (OPA Public Cloud) HTTP(s) URL based invocation of the Interview Service 100s of Thousands of invocations a day OPA Policy Hub, as another Web Application, provides the Interview Session screens using the UI as configured by the rule author.


This Assessment wizard can be made available within the “Agent Desktop” for the agent who is providing assisted service as well as embedded into the “Consumer Portal” for the consumer who is interested in achieving self-service.


It is possible to pass additional parameters through the URL, pre-load the Interview session with data from Oracle Service Cloud application and,


Persist / Save the data back into the Service Cloud application itself on completion of the interview and an appropriate assessment is made by our expert.

OPA RightNow Connector is a special implementation of the Web Service Connector architecture provided by OPA Policy Hub.


This “Connector” connects to a Service Cloud Instance as a data source and supports pre-loading and saving of data to / from the connected Service Cloud Instance.

For those of us trying to figure out the inner working of this connector, we will be using the sample rulebases provided by OPA Cloud. The complete list of example projects for the (freshly minted) Nov 2016 release of OPA can be found here. Such a hands-on exploration works best if you know both the applications well enough to administer and configure them, or spend some time together as a team that has the collective knowledge of both the applications.

The sample rulebase we use for this post is “RightNowSimple”. This is a fairly simple project that can be used to test the connectivity with the Service Cloud Instance from OPA Cloud and without making any changes to the Service Cloud Application. The supported objectives of this rulebase are

  • To collect the basic user profile information and their opt-in preference for marketing emails
  • If they opt-in, and only if, then collect the additional email address information
  • With the collected information and preferences, create a new “Contact” Record and the associated follow-up “Tasks” to be performed in the connected Service Cloud Instance.


  1. OPA Cloud Instance provisioned with the necessary connection to the Service Cloud Instance. This is an improvement from earlier versions in that Oracle, along with provisioning the OPA Cloud Instance, will also perform some of the initial setup tasks needed to connect to a Service Cloud Instance from OPA Cloud. If this is all done correctly during provisioning, you should see the following entry in the “Connections” tab of the OPA Policy Hub administration site. The green check mark against the Oracle Service Cloud Connection signifies that the provisioning is all done correctly and that the Oracle Service Cloud connection is ready to use. Please also note the use of the SOAP service end-point for the associated Service Cloud Instance.

Oracle Policy Automation Public Cloud

  1. The new Permission model in OPA Cloud allows for “Collections” to be created, for the purpose of grouping rulebases and granting permissions to users at the Collection-level. In our case, we created a collection named “Service Cloud Collection” to group all the rulebases related to Service Cloud. If this is not available, you can always use the “Default Collection”, which is made available by default in OPA Cloud. Also the OPA Cloud Admin can specify which connections each of these collections will have access to. You will further see its impact when we are ready to deploy the rulebase.
  1. Oracle Policy Modeling Version 2016 is installed on your local machine with all its pre-requisites like Java RunTime Environment and Microsoft Office Word and Excel. Note that the Java RunTime requirement is now for version 8.

Explore the RightNowSimple Rulebase:

  1. Open Oracle Policy Modeling Nov 2016 release
  1. Click on “Example Projects”, search for RightNowSimple and select the project to create the local project on your default Projects folder.
  1. Review the Rules.docx rule document and the Data tab for the included entity model, its usage of Inferred Entity Instances and application of additional reasoning with the inferred entity instance attributes.
  1. Review the Interview screen design and its usage of rules for Screen Visibility (for “email address” Screen) and Screen Control Visibility (for “Interview Complete” Screen).
  1. Review the Data Model for the entities “Global” and “the task”, their containment relationship, their respective mapping to “Contact” and “Task” entities of Service Cloud, their attributes and public “Names” for those attributes, “Mapped Out” attributes for all the inputs being sent to “Service Cloud” and the “Mapped In” attributes for the outputs being received from Service Cloud.


Oracle Policy Automation Public Cloud

  1. As per the above rulebase configuration, when the Interview is saved / submitted, a new contact record and the associated follow-up tasks are created in the Service Cloud database.

Deploy and run the RightNowSimple Rulebase

Let us now deploy this RightNowSimple rulebase to the OPA Cloud Policy Hub, using the Service Cloud Collection that is now available in the Policy Hub.

  1. Connect to the OPA Cloud Policy Hub using the appropriate admin credentials for your instance.
  1. Update the Connection used by the RightNowSimple rulebase, to make it ready for deployment.

Oracle Policy Automation Public Cloud

This can be done by clicking on the “Mapping Settings” in the tool bar or the “Global” Entity to open the “Mapping Settings” dialog, changing/selecting the Service Cloud connection used by the rulebase and then refreshing the “meta data” that is made available through this Service Cloud connection. This meta data is required to accomplish the necessary mapping between the OPA Entity model and the Service Cloud entities.

  1. Deploy a Snapshot / Activate the rulebase on the OPA Cloud Policy Hub, using the appropriate Policy Hub Admin credentials for your OPA Cloud instance. For a quick deployment and test of the rulebase, make sure that the “Activate Immediately” check box is selected and deploy. Note Down the URL.
  1. Once the deployment is complete in the previous step, you will be able to copy the Interview launch URL for this rulebase. Go ahead and launch run the interview session with any input you would like to use and complete the Interview as per the instructions provided on the screen.

Verify the results in Oracle Service Cloud:

  1. The New Contact ID displayed on the summary screen, on Interview Completion indicates that the connector worked behind the scene, using the mapping configuration modeled in the rulebase, and created the contact record in the Service Cloud instance.
  2. Now login to your Oracle Service Cloud instance to verify the new Contact record created and the associated tasks, as inferred in the rulebase. Also compare the mapping settings in the rulebase to the actual filed values that are now inserted into the Service Cloud Instance.

Oracle Policy Automation Public Cloud

With this detailed background, check this space when we will continue next with part 2 of this blog that focuses on embedding such interview sessions into the Consumer Portal of Oracle Service Cloud.