Metadata and Groovy?-?Deleting Shared?Metadata

Metadata and Groovy?-?Deleting Shared?Metadata

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.

No alt text provided for this image
Hierarchy before deleting

Refreshing the hierarchy view after the rule.

No alt text provided for this image
Hierarchy after deletion

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.

Nitin Singh

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.

回复

要查看或添加评论,请登录

Shehzad Kazmi的更多文章

社区洞察

其他会员也浏览了