Custom Functions – Use Cases and Usage #3

This is the third part of our series about the (relatively) new idea of custom functions in Oracle Policy Modeling. In this third part (see parts one and two) we look at how the concept of custom functions as entities gives us some really nice features that will enable us to produce more complex examples.

Before we go into an example, let’s set the ground rules for entities and custom functions:

  1. A custom function can have child entities (and grandchild entities). These must be inferred. There is no mechanism for the user to enter these instances. They can be inferred in the usual ways (tables, Excel inference tables, etc).
  2. The custom function and it’s child entities cannot be in a relationship from outside the function. As the documentation puts it “a relationship cannot allow a rule outside of the custom function to see instances within the custom function”
  3. In practical terms, you can get entity instances from outside the custom function but you cannot do the reverse. For all intents and purposes, the custom function is a hermetically sealed context that you can bring data into, but the only thing you can bring out is the output you specified.
  4. Error messages will appear in the Oracle Policy Modeling Data tab if you try to do this sort of thing:

So with that out of the way, let’s look at an example. We wish to create a function that will calculate the average age of people who have a stated gender of Female. The basic function rule looks like this:

No surprises there – sum the ages of people, and then divide by the number of people. Here is the definition:

Custom Functions with Entities Definition

Note there are no inputs. So where do our people come from. Here is the data model of the project (including the age() function we created in an earlier article:

Custom Functions with Entities 1

You can probably see that we have a standard entity called “the person” and then we have a child entity inside the custom function which is inferred. People who meet the relevant criteria (stated gender is female) will be inferred into the custom function child entity. For this we need to create a relationship whose target is the custom function entity. Reverse text is not permitted here (see the points above).

This is standard stuff. So now, inside the custom function, we have instances of persons to work with (but only those who have a stated gender of female).

Custom Functions with Entities 3

In the above example, we use the For() function to copy the person’s date of birth into the averagefemaleage function person’s date of birth so that the date of birth is available on the instances brought into the custom function. Then we can apply the age() function we saw in an earlier article in this series to calculate the age.

We also need to find out how many instances there are inside the custom function. So we can use the standard InstanceCount() function against the containment relationship of our child entity inside the custom function (which we renamed from “all instances of…” to “the people in the averagefemaleage function” for clarity).

And therefore we have everything we need to call the function itself and place the result in a global attribute:

This example shows how you can use child entities inside the custom function for your custom function to leverage. It is a silly example but shows the concepts and the constraints in an easy to view format. The documentation about child entities in these functions can be found here.

Here it is in the flesh:


Surprise!! There will be a part four to this series, where we will look at another cracking capability for custom functions, this time with Decision Services.

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