Grrovy_Setting_User_Variable
Grrovy_Setting_User_Variable
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.getUserVar
iable(‘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.
Lydia