Improve the Quality of Your Application & UX by Declaring Whitelisted Data Forms in a Groovy Rule

August 18, 20224 min readGroovyPlanningData Form
EPM Inception — a network of connected nodes forming a brain, in an indigo-to-cyan gradient

This post is around Oracle EPM Cloud Planning.

As I was developing some Groovy rules once, I was wondering if one of them could be executed from a limited scope of forms, because what I saw as a potential benefit would be improving the quality of the delivery whilst implementing a business requirement in a Groovy rule. Typically, I faced following situation:

  • Despite my will to limit the number of rules (less is more!), still there were lots of rules out there in Calculation Manager
  • It happened more than once that one Groovy rule was wrongly assigned to one or more data forms. Did someone say the project lies in a VUCA world? (not familiar with this acronym? check that link to know more ). If you haven’t read this post from Harvard Business Review on Agile Project Management from May 15 2018, now is the time to get your agile mindset updated.

Sorry, my mind was probably being hijacked by the BCS Foundation Certificate in Agile v2.0 that I just passed today

Prerequisites for the use case considered

Groovy rules are always developed in a extremely specific context. This context can be defined by:

  • the scope of the data form from where it’s being executed. I will call it functional context.
  • the structure of the data form from where it’s being executed. I will call it technical context.

Let’s consider we have four data forms:

  • Data Input – Top Line
  • Data Input – Fixed Costs
  • Data Input – Drivers for Variable Costs
  • Data Input – Variable Costs

Additionally, let’s consider that all of them do share design patterns for dimensionality in rows, columns and POV.

Finally, let’s assume you have one Groovy rule that handles some common behaviour expected by your end user, on the two forms for Fixed Costs & Variable Costs: be it validation rule or whatsoever.

The functional context matches the name of each data form, and the technical context is defined by the dimensional structure of the forms.

Structure and Scope of data forms

The results in a nutshell

Results do meet my expectations

The detailed results in job console

When run from the data forms specified in the Groovy rule itself, the job console shows that everything goes fine:

Form “Data Input – Fixed Costs”Job Console message statingthe rule has run

Form “Data Input – Variable Costs”Job Console message statingthe rule has run

When run from the data forms NOT specified in the Groovy rule, the job console explains the reason why:

Form “Data Input – Top Line”Job Console message stating therule was blocked

Form “Data Input – Drivers for Variable Costs”Job Console message stating therule was blocked

Also, it’s possible to prevent the execution from Calculation Manager itself:

Calculation ManagerJob Console message stating therule was blocked

Simply enhance the User Experience

I personally try to avoid designs where there is obviously an error and nothing more to help understanding (and consequently solving) the underlying problem. That said, in case the rule should NOT be run, I like displaying simple and explicit messages (“what?”, “where?” and cherry on the cake “why?” or even more by suggesting possible action to be taken) because it is obviously bringing an added value either to the consultant who is implementing or to the end user who is planning/budgeting/forecasting.

Form “Data Input – Top Line”User Interfaceerrormessage (option “Run Before Save”)

Form “Data Input – Drivers for Variable Costs”User Interfaceerrormessage (option “Run Before Save”)

Calculation ManagerUser Interfaceerrormessage

Last but not least: the names of the forms are case sensitive. It goes without saying that if requirement is to deal with non-sensitive case, this can also be implemented by making some changes to the code.

Form “Data Input – Drivers for Variable Costs”User Interfaceerrormessage (option “Run Before Save”) with intended typo in the Groovy rule

The code of the Groovy rule

DataGrid getGrid = null

def listOfFormsAllowed = ["Data Input - Fixed Costs", "Data Input - Variable Costs"]

String currentRuleName = currentRule.getName()

String msgIsFormUs = "The rule "$currentRuleName " has to be executed from one of the following forms : $listOfFormsAllowed."
def mbUs = messageBundle(["validation.isForm":msgIsFormUs])
def mbl = messageBundleLoader(["en": mbUs])

Map myMap
String currentFormName

try{
getGrid = operation.grid
myMap = operation.grid.getSourceInfo()
currentFormName = myMap["name"]
}catch(Exception){
msgIsFormUs += " Execution from Calc Manager is not possible since operation.grid is null"
mbUs = messageBundle(["validation.isForm":msgIsFormUs])
mbl = messageBundleLoader(["en": mbUs])
throwVetoException(mbl, "validation.isForm")
}

if(!listOfFormsAllowed.contains(currentFormName)) {
msgIsFormUs += " Execution from form "$currentFormName " has not been authorized by administrator"
mbUs = messageBundle(["validation.isForm":msgIsFormUs])
mbl = messageBundleLoader(["en": mbUs])
throwVetoException(mbl, "validation.isForm")
} else{
// here is the code that answers the business requirements
println("Script executed from dataform "$currentFormName "")
}

Of course, there is always room for improvement, and you may connect your inner dots to find some other use cases. Feel free to share any idea around this in the “Leave A Reply” section below. Yet another seed that may grow your EPM dreams…