Forum Discussion

KH1's avatar
KH1
Contributor III
7 months ago
Solved

Business Rule | One-to-One Transformation - E# Parent to its first E# Base

We need your help to Import flat files: 1. > 100k Rows by 1,000s of E# Parent Members 3. E# is extended We've been fortunate to be advised to build a BR to generate a one-to-one Transformation Ru...
  • BenEppel's avatar
    7 months ago

    I believe something like this should work within a complex expression on a transformation rule (did not test). The dimension name logic may need some tinkering and I am not sure about the order of the base members being returned. If that's an issue you could tag the base member you want within a Text field and then include a where clause in the member filter so it will only return the member you want data loaded to. If no base members are returned it defaults to the source value. You might also need error handling if the source value isn't a valid member.

                Dim DimensionToken As String = "E#"
                Dim ParentMem As String = args.GetSource(DimensionToken)
                If String.IsNullOrEmpty(ParentMem) Then Return Nothing
    
                ' Hardcode or replace with your logic to determine the dimension name
                Dim DimensionName As String = "Entity"   ' <<< set appropriately
    
                ' Get base members under the parent (metadata order)
                Dim BaseMems As List(Of MemberInfo) =
                    BRApi.Finance.Metadata.GetMembersUsingFilter( _
                        si, DimensionName, DimensionToken & ParentMem & ".base", True)
    
                If BaseMems IsNot Nothing AndAlso BaseMems.Count > 0 Then
                    For Each mi As MemberInfo In BaseMems
                        If mi IsNot Nothing AndAlso mi.Member IsNot Nothing Then
                            ' Return the first base member name
                            Return mi.Member.Name
                        End If
                    Next
                End If
    
                ' If no base descendants, return the parent itself
                Return ParentMem