Metadata and Groovy?-?Deleting Shared?Metadata
Shehzad Kazmi
Currently @ Oracle | Digital Transformation Specialist | EPM Solutions Advisor | Budgeting & Planning | Profitability and Costing | Helping businesses to realize value from their EPM investments | AI enthusiast
Groovy and Metadata: Unlocking the Vault to Shared Member Deletion
In this part of the Metadata and Groovy series, I will explore how you can harness the capabilities of Groovy to delete shared members dynamically.
Take a look at the Create Shared Metadata post to see how we can create shared metadata.
Deleting Shared Member
Let's start with the script
/*RTPS:*/
Cube cube = (operation.hasCube() ? operation.getCube() : operation.application.getCube("OEP_WFP"))
Dimension dim = operation.application.getDimension("Employee", cube)
Member mbr = dim.getMember("E00XX", cube)
List<Member> sharedMembers = mbr.getSharedMembers(cube).findAll({Member it -> it.toMap()["Parent"] == "WCP_Employee Analysis"})
sharedMembers.each { Member deleteMbr ->
? println("Deleting ${deleteMbr.name}")
? deleteMbr.delete()
}
When we retrieve the member, it fetches the base member, which we can then use to get the shared instances. In my script I've hard-coded the filter to check if the parent is WCP_Employee Analysis so even if we had other shared instances, we won't end by deleting them.
Running the script, I am deleting the shared member that I had created in the Creating Shared Metadata post.
Refreshing the hierarchy view after the rule.
Rule log, confirming that it is indeed deleted.
Log messages :
Deleting [WCP_Employee Analysis].[E00XX]?
Conclusion
In this part of the Groovy and Metadata series, I have covered how you can delete a shared dimension Member.
Using the delete() method of the Member class we can delete the shared member by ensuring that the Member object refers to the shared member and not the base member.
EPM Consultant at Intellicore Consulting Group
1 年That's indeed a great script, which will save a lot of time in finding and deleting shared members manually.