Forum Discussion

MarkBird's avatar
MarkBird
Contributor III
2 years ago

ParentMemberId is always -1?

Hi I have got a list of member info and trying to do a simple loop through the list to get the member and it's parent using the following code, however ParentMemberId is always coming back as -1. ...
  • JackLacava's avatar
    2 years ago

    I suspect that GetMembersUsingFilter always returns a flat list of members, regardless of the filter expansion you use - hence, without parent IDs set.

    MemberInfo, as a class, can express parent-child relationships and indentation levels, but not all functions that produce MemberInfo objects will actually leverage such power.

    When I was in a similar situation I ended up parsing the tree top-down, calling .GetChildren on the top member and then recursively on all descendants. At that point, I could keep track of relationships myself in an explicit manner. More work, I know...