Oracle Process Cloud Service (PCS) is great! You can build process-based applications in two shakes of a lamb’s tail, much quicker than most Low Code platforms in the market. Of course, you can’t, or at least shouldn’t, develop any “normal” master-detail CRUD application with Oracle Process Cloud Service. If you need this kind of applications perhaps Oracle Application Builder Cloud Service will suit you better, but for process-centric applications, it’s a hard to beat tool.
As you may know, Oracle also has an on-premise product, called Oracle BPM, which features a similar codebase, but it features a more advanced and complex UI and it takes a bit more time to produce a similar application.
Oracle PCS really shines for its simplicity and ease of use, because the UI was streamlined and is much more focused. However, all this optimization and streamlining led to decisions to simplify the UI and some features present in Oracle BPM are not present in Oracle PCS. Most of them we won’t really need except for 1% of all our application needs, but a few are a more common necessity. The capacity to use functions to manage and operate dates and times fit this last set.
Oracle BPM allows you to manipulate dates using several options, with Data Associations and Script tasks perhaps being the most common. In Oracle PCS, the Data Associations don’t allow you manipulate dates nor retrieve the current Date / Time, and script tasks plain and simply are not available.
It’s possible to create services that do whatever we need to do with dates and then call them in Oracle PCS, but sometimes we want a more direct approach.
The Use Case
Let’s consider the following case:
We have a simple approval process with 3 steps. Every time there’s a response to a task, we want to record which response was and at which date and time it was made. We also want to show this information to the user, in the task web form, and we want that the whole process takes a calculated amount of time as the most, with it automatically finishing up after that amount.
Something a bit like this:
And the web form:
Notice that Oracle PCS automatically creates a data object in the process, of the same type as the start form.
Also, all task data associations are done automatically, without the need to do this manually, when you set the task form.
Remember that we want to fill each of the decision fields with both the Outcome of the last response and the date and time of that response.
If we try to so it through the web form functions, you’ll notice that you can only set a field to the current date/time. This would change the value of the field “When?” every time the user was shown the form. This is not what we want.
Also, you can’t do calculations between fields which are of type date/time. Let’s say you also want a new field which tells you the number of days between the date of the first decision and the last one. How can you calculate this in the form?
Common sense would lead us to try to subtract the value of the field that holds the date/time of the first decision, from the value of the field that holds the date/time of the last decision. Unfortunately, this doesn’t work, as you can see below (31 May – 18 May = 0)
We can also try the data association route, but, as we can see from the image below, there are no functions to deal with dates in this part.
Finally, as there are no Script Tasks, as you have in Oracle BPM, you can’t actually program this in your process.
So, how can we do this?
Let’s try to use a Business Rule for this. By placing a Business Rule after each task, we guarantee an immediate execution right after the decision is taken and we record the rule execution date/time as the decision date.
Business Rules Calendar objects
Business rules get an input, do some magic, and produce an output… pretty much as any other task in our process. What makes them special is the amount of magic one can do inside them.
When we create a decision, we can use a lot of Java functions, including a few related to treating dates and times.
So we create a Business Rule, setup the input and output as objects of the type of the web form (this makes it easier to do the data associations) and, once we enter the decision screen we just create a new General Rule.
Then we create a true condition in the “If” part of the rule, as we want it to always execute, and in the “Then” part, we specify that we want to modify the object that we specify in the Drop Down List (in the example below the object is called “Other”).
We click on the pencil icon and choose the field in which we want to do the date processing (click on the magnifying glass). We are taken into the Condition Browser, where we can access the Expression Builder
As you can see, this expression builder is much more advanced than the one available in the Data Associations dialog, with a few more tabs, including the Functions.
In here we can do calculations with our dates, set them as we want.
So we’ll grab the CurrentDate.date.time calendar and apply the JavaDate.to datetime string to it, like so:
And that’s it. This will calculate the current date and time, put it in the output object, which is our web form.
Now we only need to repeat for all tasks. A bit like this:
I hope that this article can help you do more complex calculations and extend the normal use of Oracle PCS, to cope with more business scenarios.
If you have any questions please place them in the comments box below.
P.S: All of this could also be done with the help of ICS, JCS or ACCS. I’ll write about it in a couple of weeks.
Post header image by Sebastien Wiertz