The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.

Forum Discussion

JoBo's avatar
JoBo
New Contributor II
2 years ago
Solved

Memberlist based on Datatable returns nothing

Hi guru's 

I have created some memberlist logic which should retrieve a list of entities from a datatable. So far so good, the code seems to work (logging returns my expected entities) but the return function doesn't do anything...

Looks like I'm missing something but I do not know what...If someone has the magic solution I'll give my kudos 🙂

 

Thanks alot!

 

Rgrds Jorrit

 

Case Is = FinanceFunctionType.MemberList
'BR String: E#Root.CustomMemberList(BRName=Mars_memberlists, MemberListName=[Mars_CustomMemberList], Striplist=|!prm_StriplistName!|)
 
If args.MemberListArgs.MemberListName.XFEqualsIgnoreCase("Mars_CustomMemberList") Then
 
Dim sStriplist As String = args.MemberListArgs.NameValuePairs("Striplist")
' Build the header
    Dim listHeader As New MemberListHeader("Mars_CustomMemberList")
' Construct the SQL query
Dim tempsql As New Text.StringBuilder
tempsql.AppendLine("SELECT UN_ID")
tempsql.AppendLine("FROM XFC_Mars_Striplists")
tempsql.AppendLine("WHERE STRIPLIST_NAM = '" + sStripList + "'")
    Dim listOfMemberInfos As New List(Of MemberInfo)()
' Retrieve the DataTable using the DBConnInfoApp object
Using dbConnApp As DBConnInfoApp = BRAPi.Database.CreateApplicationDbConnInfo(si)
    Using dt As DataTable = BRAPi.Database.ExecuteSql(dbConnApp, tempsql.ToString(), True)
        ' Build the list of MemberInfos from the UN_ID column of the DataTable
    
        For Each row As DataRow In dt.Rows
            Dim unId As String = row("UN_ID").ToString()
            Dim memberInfo As New MemberInfo(unId) 
            listOfMemberInfos.Add(memberInfo)
        Next
      End Using
End Using      
 
        ' Log the list of member names
        Dim memberNames As String = String.Join(System.Environment.NewLine, listOfMemberInfos.Select(Function(member) member.UN_ID))
        api.logmessage("List of Membernames", memberNames)
 
        ' Build and return the member list
        Dim memberList As New MemberList(listHeader, listOfMemberInfos)
        Return memberList
 
End If
 
End Select

 

  • I think the problem is that it does not know what dimension the member info list is for. I haven't tested this but it should put you on the right path:

    Dim unId As String = row("UN_ID").ToString()
    Dim EntMemID As Integer = api.Members.GetMemberId(DimType.Entity.Id, unID)
    Dim memInfo As MemberInfo = New MemberInfo(api.Members.GetMember(DimType.Entity.Id, EntMemID))
    listOfMemberInfos.Add(memInfo)

     

2 Replies

  • MarcusH's avatar
    MarcusH
    Valued Contributor

    I think the problem is that it does not know what dimension the member info list is for. I haven't tested this but it should put you on the right path:

    Dim unId As String = row("UN_ID").ToString()
    Dim EntMemID As Integer = api.Members.GetMemberId(DimType.Entity.Id, unID)
    Dim memInfo As MemberInfo = New MemberInfo(api.Members.GetMember(DimType.Entity.Id, EntMemID))
    listOfMemberInfos.Add(memInfo)

     

    • JoBo's avatar
      JoBo
      New Contributor II

      Works brilliant, thanks a lot Marcus:rocket: