Brovanture Oracle Cloud EPM

Oracle Cloud EPM – setting user variable default values using Groovy

Lydia Maksoud
Brovanture Senior Consultant

Groovy is a standard scripting language which is available in Oracle Cloud EPM applications to allow dynamic customisation in multiple contexts around the system. The availability of Groovy is dependent on the Oracle Cloud EPM licensing; groovy scripting is available for Oracle Cloud EPM Enterprise applications only.

As with all coding languages, use of the documentation is key and Oracle have provided a brilliant scripting reference which can be found here: https://docs.oracle.com/en/cloud/saas/applications-common/22b/cgsac/groovy-basics.html

In this blog we will focus on setting user variable values using Groovy. User variables are administered by individual users and can be used on forms to show only relevant information to the specific user. It is useful to set default values for users so that they can open forms which utilise the user variables, without having to manually set them first.

In the below example, we will be using groovy to set a default value for the MyRegion user variable, which is setup for the Region dimension. This will pick up the first available region member for the user, depending on the security for the user that runs the rule.

The below script performs the following steps:

  1. Check whether the user variable has a value, or not (i.e. is null)
  2. If null, then retrieve the Region dimension
  3. Set member function to retrieve all Region members under ALLREG (All Regions)
  4. Check number of region members that user has security access to
  5. If members are available, set the MyRegion user variable to the first available member
  6. Print a line in the log to indicate the setting

 

 if(operation.application.getUserVariable(‘MyRegion’).getValue()==null){

  //MyRegion User Variable is not selected

    Cube cube = operation.application.getCube(“FinPlan”)

            Dimension dim = cube.getApplication().getDimension(‘Region’);

            String memberfunction = ‘ALLREG,Descendants(ALLREG)’

            def mems = dim.getEvaluatedMembers(memberfunction,cube)

if(mems.size()>0){

  operation.application.setUserVariableValue(operation.application.getUserVariable(‘MyRegion’),mems[0])

  println “MyRegion User Variable is selected to ” + operation.application.getUserVariable(‘MyRegion’).getValue()

}

}

else {

println “MyRegion User Variable is selected to ” + operation.application.getUserVariable(‘MyRegion’).getValue()

}

 

Save this script in a business rule, with a relevant name, making sure to select the rule type as Groovy. Assign the business rule to a task list, or a form in the navigation flow, for each user to run before opening any forms which utilise the user variables.

Until next time.

Lydia

If you want help with Groovy we already have considerable experience of using Groovy with many of our clients and can be contacted at the phone number at the top of this page or via our contact page HERE.

I also blog on Blogspot HERE