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

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Oracle Policy Automation and Siebel Innovation Pack 16 #1

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

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

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.