10-05-2022 07:10 PM - last edited on 05-24-2023 08:23 AM by JackLacava
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)
Next
10-06-2022 12:49 PM - edited 10-06-2022 12:50 PM
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.
-DB
10-10-2022 01:35 PM
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, _
None)