Custom Functions – Use Cases and Usage #2

Following on from the previous article in this series, where we looked at the basics of custom functions, this article continues in the same way and demonstrates another way to create custom functions and a great use case.

In the first article, we illustrated the two parts of the function – the structure, which is defined in a dialogue box in Oracle Policy Modeling, and the rules themselves which explain how to arrive at your output. We also highlighted that rules can contain anything you would normally use in Oracle Policy Modeling rules – other functions (including other custom functions that you have defined), other attributes and so forth.

So, in an important step, it is key to understand that you could use Excel (or a combination of Word and Excel) to arrive at your output. Consider a common problem in larger calculation projects. Often, these calculations are conditioned by reference data. As an example, the price of a transport ticket might be reduced based on your circumstances – unemployed people get 10% discount. Large families get 20% for any child after the first three. Children might get a discount of 50% if they are under the age of 16 and are not part of a family ticket…and son. These percentages (10%,0%, 50% discounts) are unstable in nature – they change because the government, agency or company reacts to some event like a yearly review or a major policy change.

To make matters more complex, many rule projects have hundreds of these reference items, often with opaque names that correspond to some government document or announcement somewhere. For example subject matter experts might be able to make sense of the following:

SMIC39 Hours per Week> 2024-01-01EUR 1968.85
SMIC35 Hours per Week> 2024-01-01EUR 1334.67

This actually refers to the minimum wage in France, depending on the amount of hours in your contract. The most common place to store these reference data is in a Table, often Excel, and of course in real life there are many more lines, and many more pieces of reference data, not just the SMIC, and they are mentioned in hundreds of locations in Word and Excel rules, so management of the reference data needs to be handled properly. Let’s look at a simple example.

In the table above, to make things more realistic, there is a second piece of reference data with another code BMAF. It does not have any modifiers – the only thing that matters is the date. the SMIC on the other hand uses a modifier concerning your working hours.

custom functions - reference data

Above you can see a custom function definition. Note that the output is the value of the SMIC (or whatever the reference data is). So the function contains three arguments as input – the code (SMIC, BMAF and so on) and the modifier (if needed) and the date. Currently there is no mechanism to say an input is optional. The output is the value.

So now we can use our function to extract values from our table, for the different reference data items, in a generic way. And of course, we can use attributes in place of constant values:

Which means that we now can extract the correct values for any situation, for example if there is an entity called the person:

And to finish, the bonus with this setup is that because a custom function is essentially self-contained, it can easily be added to a project that is going to be an inclusion in others. So rule authors can benefit from your custom function in the future.

In part three we will see how custom functions really are entities – we will create child entities, relationships and look at how Decision Services can play a major role in a custom function. It’s going to be great!

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 intelligent-advisor.com, 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