The blog delves into leveraging Groovy’s capabilities to dynamically add UDAs (User Defined Attributes) to Dimension members. By harnessing Groovy’s capabilities to dynamically add UDAs to Dimension members, consultants can achieve a higher degree of customization and scalability. As systems grow and evolve, the ability to dynamically add UDAs becomes increasingly valuable.
Below is the code snippet and its execution:
/*RTPS:*/
Cube cube = operation.application.getCube(“OEP_FS”)
Dimension dimEntity = operation.application.getDimension(“Entity”, cube)
Member mbrALIC = dimEntity.getMember(“11”)
Map mbrMap = mbrALIC?.toMap()
println(“ALIC (member 11) – Before Adding UDA”)
println(mbrMap)
println(“—“)
List<String> udas = ((String)mbrMap[“UDA”])?.split(“,”)*.trim() as List<String>
udas += [‘Type_HO’, ‘Geo_IN’] – udas
mbrMap[“UDA”] = udas.join(“, “)
println(“ALIC (member 11) – After Adding UDA”)
println(mbrMap)
println(“—“)
Member savedMember = dimEntity.saveMember(mbrMap, DynamicChildStrategy.DYNAMIC_IF_AVAILABLE)
println(“ALIC (member 11) – After Saving”)
println(savedMember?.toMap())
println(“—“)
Before running the script:
The script will reveal whether your system is 32-bit or 64-bit, which is crucial for downloading the appropriate Oracle Java binaries.
After running the script:
The execution log will show the addition of UDAs to the member “11” dynamically. The log should show there were no UDAs assigned. After execution, “Type_HO” and “Geo_IN” UDAs were added to member “11” whose alias was ALIC in my application and printed in logs as well.
Going forward we can use variables or RTPS to set particular UDA to a list of members using similar Groovy script.
Conclusion:
This blog illustrates the process of adding UDAs to a dimension member. By utilizing the toMap() and saveMember() methods from the Member class, you can traverse, update and save the member properties.
Stractive offers a free of cost, no obligation migration readiness assessment to do TCO & ROI analysis, gauge health of the current setup and recommend future roadmap. For more information reach out to sales@stractive.com.