Entity Parent Under a Specific Hierarchy


Hello -

I am am trying to produce the parent for an entity under Gathering_Processing segment node. However, because this entity is shared, the parent entity returned by the VB below is not the one I need. The parent returned is RRC_STXGasUtility which is flat hierarchy and includes the entity in question. Can you please advise?



Dim ggpelimftr As String = "E#Gathering_Processing.Descendants"
Dim ggpList As List(Of MemberInfo) = api.Members.GetMembersUsingFilter(api.pov.EntityDim.DimPk, ggpelimftr, Nothing)

For Each ggpe As MemberInfo In ggpList
Dim parentIdstring As String = String.Empty
Dim ParentList As List (Of Member) = api.Members.GetParents(api.Pov.Entitydim.DimPk,ggpe.Member.MemberId,False)
Dim ParentMember As String = ParentList.First.ToString
Dim ParentArray() As String = Split(ParentMember)
parentIdstring = ParentArray(2).Replace(",", "")
parentId = Convert.toInt32(parentIdstring)



Contributor III

Hi Oscar:  I think your issue is:

Dim ParentMember As String = ParentList.First.ToString

You are forcing the first member returned from GetParents, but the there are multiple parents for the entity and the returned order will not necessarily follow the order you see in your search screen.

I think you need two lists, the GetParents of your base entity and the Descendants of your E#Gathering_Processing.  Then compare them and return only the matching one.


Community Manager
Community Manager

Hey Oscar,

another technique you can consider is to use isDescendant on the parents you retrieve:

Dim isTheRightParent As Boolean = api.Members.IsDescendant(dimPk, _
                                GatheringprocessingMemberId, _
                                memberIdOfParentYouRetrieved, _