This is a very powerful functionality in groovy. I noticed I keep using this in my projects and never had a chance to write about it before. I am saying this is powerful just because you can leverage this mechanism to switch your application from old school “calculate all” approaches to groovy way which can identify the cells to be calculated and runs business rules in focused slices of database or do focused data map executions. Here is one code snippet to capture all edited entities.

def arrEditedEntities = []
operation.grid.dataCellIterator{DataCell cell -> cell.edited}.each{
   arrEditedEntities.add(it.getMemberName("Entity"))
}
println(arrEditedEntities.unique().join('","'))

you can use the array inside the script which will enable you to dynamically populate the Fix statement with the edited entities only.

def script = '''
...
FIX (&CurrScenario, &CurrVersion, "'''+arrEditedEntities.unique().join('","')+'''", "No Customer")
...

Well, instead of having another step in the process to calculate all entities in the absence of not knowing which entities are updated. This approach allows you to calculate only a portion of the cube. It is naturally performing much faster and allows users to access their calculated number in the reports quicker. You may want to use entity array in different ways. Here is a loop example.

arrEditedEntities.each{ e ->
def params = new JSONObject()
  .put("RTPEntity",e.toString())
  .put("Scenario",arrScenarios[0].toString())
  .put("Version",arrVersion[0].toString())
  .put("Periods",'"'+arrPeriods.unique().join('","')+'"')
  .put("Years",'"'+arrYears.unique().join('","')+'"')
def body = new JSONObject()
  .put("jobType","Rules")
  .put("jobName","Data Push2RPT")
  .put("parameters",params)
  .toString()
}

Correct, this loop is creating the rest api body to initiate another business rule which could be triggering a focused data push. I am not covering how to initiate a job from groovy or data push. You can find examples in my previous blogs.