cancel
Showing results for 
Search instead for 
Did you mean: 
OSAdmin
Community Manager
Community Manager

Used to suppress inactive Entities from consolidating in a structure for a given period.

 

       If Not String.IsNullOrEmpty(timeName) Then
        timeId = api.Members.GetMemberId(DimType.Time.Id, timeName)
       End If

       'Start with a list of top entity members using the passed-in TopEntityFilter. 
       'The filter should just represent the top members as a starting point (e.g., E#Root.Children)
       Dim topEntityFilter As String = args.MemberListArgs.NameValuePairs.XFGetValue("TopEntityFilter")
       If String.IsNullOrEmpty(topEntityFilter) Then
        topEntityFilter = "E#Root.Children"
       End If
       Dim topEntities As List(Of MemberInfo) = api.Members.GetMembersUsingFilter(api.Pov.EntityDim.DimPk, topEntityFilter, Nothing)

       'Use recursion to add these top entities and then the child hierarchies beneath each entity.
       Dim allEntities As New List(Of MemberInfo)
       RecursiveAddParentsAndTheirChildrenToList(si, api, scenarioTypeId, timeId, DimConstants.Unknown, -1, topEntities, allEntities)

       'Return the list.
       Dim objMemberListHeader As New MemberListHeader(args.MemberListArgs.MemberListName)
       Dim objMemberList As New MemberList(objMemberListHeader, allEntities)
       Return objMemberList
      End If
    End Select

    Return Nothing
   Catch ex As Exception
    Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
   End Try
  End Function

  Private Sub RecursiveAddParentsAndTheirChildrenToList(ByVal si As SessionInfo, ByVal api As FinanceRulesApi, ByVal scenarioTypeId As Integer, 
     ByVal timeId As Integer, ByVal grandParentEntityId As Integer, ByVal grandParentIndentLevel As Integer, 
     ByVal parentEntities As List(Of MemberInfo), ByVal allEntities As List(Of MemberInfo))
   Try
    If Not parentEntities Is Nothing Then
     For Each parentEntity As MemberInfo In parentEntities
      If Not parentEntity Is Nothing Then
      
       'Determine if this entity is active.
       'Check if the Entity Text 1 field on Relationship Property is set to Inactive.
       Dim isActive As Boolean = True
       If grandParentEntityId <> DimConstants.Unknown Then
        Dim relationshipText1 As String = api.Entity.RelationshipText(parentEntity.Member.MemberId, grandParentEntityId, 1,scenarioTypeId, timeId)
        If relationshipText1.XFEqualsIgnoreCase("Inactive") Then
         isActive = False
        End If
       End If
       
       'Add this parentEntity and its descendants if isActive is True.
       If isActive Then
        parentEntity.IndentLevel = grandParentIndentLevel + 1
        allEntities.Add(parentEntity)
        RecursiveAddChildrenToList(si, api, scenarioTypeId, timeId, parentEntity, allEntities)
       End If
      End If
     Next
    End If
   Catch ex As Exception
    Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
   End Try
  End Sub

  Private Sub RecursiveAddChildrenToList(ByVal si As SessionInfo, ByVal api As FinanceRulesApi, ByVal scenarioTypeId As Integer, 
     ByVal timeId As Integer, ByVal parentEntity As MemberInfo, ByVal allEntities As List(Of MemberInfo))
   Try
    If Not parentEntity Is Nothing Then
     
     'Get the child entities beneath this parent entity.
     Dim filterForChildren As String = "E#[" + parentEntity.Member.Name + "].Children"
     Dim childEntities As List(Of MemberInfo) = api.Members.GetMembersUsingFilter(api.Pov.EntityDim.DimPk, filterForChildren, Nothing)

     'Recursively add the children to the final list of memberInfos.
     RecursiveAddParentsAndTheirChildrenToList(si, api, scenarioTypeId, timeId, parentEntity.Member.MemberId, parentEntity.IndentLevel, childEntities, allEntities)
     
    End If
   Catch ex As Exception
    Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
   End Try
  End Sub

  End Class

 

Source:  Marketplace Solution - Snippet Editor  Author: OneStream

Version history
Last update:
‎03-03-2022 09:06 AM
Updated by:
Contributors