A short post on the mechanics of Process Decisions - quotes from the docs, in bold and italics. Think of Process Decisions as a service that can be invokes from a Process or via its REST api.
Let's go through these individually -
Decision services need input data, let's use the simple example of an Order.
This is simply a placeholder - i.e. used for top level decision modeling, then gets set to a particular decision type when we come to implementation.
A context is a collection of one or more key-value pairs with an optional result field. Each pair is called a context entry. The key attribute within a context entry acts as an identifier to its corresponding value attribute.
Here's a simple example, based on my ubiquitous Order Approvals scenario.
The context is for auto-approval, and, as such contains the logic to validate whether an order should be auto-approved -
Note the use of nested contexts here -
The logic is as follows - if an order is < 20k and the customer has placed more than 10 orders, then it is auto-approved. Here is the first part -
As you can see, I have added a couple of keys and set some of them to the input values -
The output (Result) of this section is a boolean - is the total order value les than the limit?
Now to part 2 -
Now to wire input to context and test -
I expose as a Service and Test -
I try with a valid order value but only 3 orders to date -
Here is a simple example - implementing the rule that the product, iScooter, cannot be sold in Ireland.
Let's test again -
Now test with country = "UK" -
An expression is a logical notation, defined according to the syntax of FEEL, that evaluates to a single value. It may consist of one or more entities, such as a literal, constant, or variable, interconnected by zero or more operators. In Oracle Cloud Infrastructure Process Automation, you can also use outputs of other decisions or built-in functions to define an expression.
That may seem rather cryptic - so here's a simple example
Here's a simple example - here I will create an expression that can be used in the following IF THEN rule.
Being connected to the input payload means my expression can use its values.
Now to the IF THEN rule -
If you feel the need to learn more about FEEL (Friendly Enough Expression Language)
, then click here
Let's test our ruleset again now -
The results -
LargeOrderValueRule returns false as 10 * 200 is less than 20k.
The Decisions Service includes built-in functions e.g.
These include the using date, string processing, list processing, if/then etc. You can create your own functions for logic not covered by these. Let's have a go at it then!
I want to give a special discount in the month of December, in honour of the Celtic feast of Imbolc.
Other months also get a discount - the Celts love a party!
As you can see, I have created a new function (fx) along with a new inputField (in_orderMonth). I have also added a new expression (ExprHolidayDiscount). Let's look at each of these -
in_orderMonth is just a text value e.g. Dec (December) -
The Function is defined as follows -
Here I apply a 15% discount for orders during Imbolc (Dec).
No discounts in Jan, but from Feb onwards we progress by 1% each month!
The expression is defined as follows -
Let's test this out -
Now test with the month of Nov (November) -
A simple example to demo the use of Decision Service Lists -
Let's begin with the ProductList -
Self-explanatory. The input, in_product, defines the input variable for this use case e.g. a Text value e.g. iBike.
The IF THEN, ValidProduct, is defined as follows -
The usual test...
Relations can be used to create a table like structure containing multiple expressions - e.g.
Note how I am leveraging the existing ProductList and HolidayDiscount expression here.
Let's see how it could be used in a IF THEN rule -
Let's test - ensuring the maximum discount -
Create loops to iterate over lists or arrays. Using the loop logical notation, you can create three different types of loops, namely For, Some, and Every.
Again, let's have an example - I begin with the following input Order with multiple order lines -
Now to the Loop definition -
I begin by just iterating over the product prices -
For - here I just specify a variable - orderPrice
In - here I point to the order price -
return - my variable.
Let's test this out -
Now I can revisit the loop definition and add the duty.
Invoking Decisions from Business Processes
Firstly, I can decide how to expose the decisions as services -
Here is my rich set of decisions, now I can decide which ones to expose as Services -
Invoking Decisions via the REST api
The URL can be found here -
Process Decisions help you implement complex business logic quickly. Such decision based logic can be easily leveraged from your processes as well as via the REST api.