1. Modify Hierarchy based on Smart list selection in Data Forms
A few years ago, if a client asked if they could move members in their Hierarchy based on their input via forms, I would have politely said its not possible. But Groovy has changed the game and I believe we are just exploring the tip of the iceberg. It felt right, to share this as my first blog with an intention of my admiration of the immense possibilities in EPM with Groovy, now that nothings impossible.
So the business requirement was simple, I have some Projects which can be active or inactive on a business cycle, and my logics should run only on the active ones. An optimized solution would not involve complex metadata management as part of their process. Groovy to the rescue.
Solution was to create a Form where Users would use Smart List to tag members as active and inactive. Upon saving the form would trigger a groovy rule via rest api to take value of Smart List and move the members out from the main hierarchy.
The groovy code can also be enhanced if needed to add a refresh database section to the end, with a prompt of Y and N to refresh it upon saving or keep it for later depending on the need of the modified hierarchy.
The following code did the trick for me:
rowHeaders.each { mbrName ->
Member objProjectMbr = dimProject.getMember(mbrName)
Map mbrProperty = objProjectMbr.toMap()
mbrProperty[“Parent”] = smartListLabel.toString()
dimProject.saveMember(mbrProperty)
println “Moved member ${mbrName} to parent ${smartListLabel}”
I am hoping this would be helpful for you, and I hope to share my experiences with Groovy and other EPM tools in the future. If you see any other use cases where this can be used, or a better way to do it, do let me know in your comments or email, and I would be very happy to discuss.
Leave a comment