Recursively listing elements of a hierarchy

HI, I am building my first test app and feel like I might be missing some fundamental concept. Appreciate your thoughts.

App has users organized in a hierarchy(think of a typical org structure CEO -Multiple VPs- Each VP with multiple Managers and each Manager with multiple Individual contributors). Any user should be able to see all users below them in their tree.

I added a manager field to the User Data Type and setup data where each user is pointing to another user as "manager’. Setup Privacy rule where you can see yourself or user’s manager as current user. This works for one level, but doesn’t traverse below that. So, if a a Manager logs in, it shows Manager + direct reports. FOr VP, only shows VP and Manager, not Manager’s reports.

Feel like I am missing something basic. Appreciate your help.

Hi there, @subbud… if I understand your post correctly, it sounds like the app is behaving as expected given the setup you described, meaning the app can’t traverse past the direct reports level because that is the only level defined in your data structure.

As with all things Bubble, there are multiple ways you can go (for example, you could simply add a list field to the User data type that stores all of the users in a user’s chain of command), but here is one thing to keep in mind. There is a well-documented limitation of privacy rules where if you don’t have a direct relationship between a user and every user in their chain, you won’t be able to create a privacy rule that allows the “indirectly-associated” users to be found in searches.

Anyway, just some food for thought there, and I hope it helps.

Best…
Mike

@mikeloc Thank you so much for your response! Now I understand the indirect-association limitation. I also was trying a privacy rule like This User’s ->Manager’s->VP is Current User and that didn’t work for the reasons you have pointed out. Thanks for your help!

1 Like