One of my coworkers recently asked if there was a simple way to extract all the smart lists connected to members. The idea was to remove all unused smart lists. I could not do it in one step since smart lists might be associated with any member from any dimension. I don’t want to download and filter each dimension metadata file individually. It turns out that retrieving the list of associated members using Groovy is a fairly simple task. Please comment if there are any alternates available.
Steps:
- Iterate through each cube and get all the dimensions
- Iterate through each dimension’s members.
- If any members are associated with a smart list, filter them out.
Get Each Dimension’s IDescendants
To ensure that no members are omitted, it is important to scan all dimensions from all cubes.
Cube[] cubes = operation.application.getCubes()
Set<Member> smartListMembers = []
cubes.each {Cube cube ->
println "Processing Cube : $cube.name"
List<Dimension> dimensions = operation.application.getDimensions(cube)
dimensions.each { dimension ->
smartListMembers.addAll (dimension.getEvaluatedMembers("Idescendants(${dimension.name})", cube).findAll{it.hasSmartList()})
}
}
Print the results in the console log:
smartListMembers.each { Member member ->
println ("Smartlist : $member.smartList.Name | Dimension : $member.dimension.name | Member : $member.name" )
}
Output
Current Smart Lists
Job Console Output
This functionality might not be very impactful. But I think it would be helpful to simply detect the inactive smart lists and save a few minutes of manual tasks. I hope this knowledge is helpful.