The Groovy Calculation Manager rule is dynamic, it gets the account member from the data form, and depending on the selected account member the rule will perform a specific calculation.
We can use the same rule and attach it to multiple Data forms.
Let's see how the rule looks,
Set<String> editedMembers = []
operation.grid.dataCellIterator({DataCell cell -> cell.edited}, MemberNameType.ESSBASE_NAME).each { DataCell cell ->
//editedMembers << cell.periodName << cell.getMemberName("Product")
editedMembers << cell.periodName << cell.getMemberName("Years") << cell.getMemberName("Product") << cell.getMemberName("Customer")
}
if(editedMembers.size() == 0){
println("No edited cells found!")
return;
}
Set<String> editedAccounts = []
operation.grid.dataCellIterator({DataCell cell -> cell.edited}, MemberNameType.ESSBASE_NAME).each { DataCell cell ->
editedAccounts << cell.getMemberName("Account")
}
This script captures the edited periods and products in a grid and generates a calculation script based on the edited accounts.
First, it initializes two sets to store the edited members and edited accounts respectively. It then iterates through each data cell in the grid and adds the period name, years, product, and customer members to the editedMembers set if the cell has been edited.
It also adds the account member to the edited accounts set.
if(calcScript == "") {
println("No matching edited accounts found!")
return;
}
println("The following calc script was executed by $operation.user.fullName: \n $calcScript")
return calcScript.toString()
Finally, it prints the calc script to the console and returns it as a string. If no edited cells or no matching edited accounts are found, it prints a corresponding message to the console and returns nothing.
We modified the % for May to 5% and saved the Data From.
If you notice the rule ran only for the May FY24 and ran the specific calculation.
The Output is given below, only for the May FY24.
The complete program is here.
Pretty cool right, Happy days ahead with Cloud!!!
No comments:
Post a Comment