Privacy using a nested search instead of field on datatype - is this a bad idea? Other options?

In my app’s database, I have Users and I have Posts.

Posts are created by Users.

The User datatype has a field Posts are Private = yes / no

I want the User to be able to choose whether their Posts are public (and viewable by all other Users) or private (and viewable only by them).

Initially, I wanted to use a Privacy Rule like this: This Post’s User’s Posts are Private is yes"… to restrict access.

It seems like that isn’t possible.

I am trying to avoid adding a field to Post like Post is Private that I would need to update every time a User changes their Posts are Private field. I’m imagining a User flipping their privacy on and off and backend workflows or database triggers flying all over the place trying to update thousands of Posts. Sounds like a nightmare.

I am considering doing it via restrictions in a search.

Search for Posts where

And then do a search in the constraint:

I’m not that familiar with nested searches. Is this a bad idea for performance or WUs? Wondering if there is something I haven’t considered, or if there might be a better way to achieve this “privacy setting”.

Thank you!

Avoid nested search as much as possible it is bad for peformance. Take a hard look at your database most of times nested searches can be avoided just by creating some extra datatypes

I have not read your entire post and just saw you have Search for Users as a constraint in the Search for Posts. Let’s solve that first.

Have a repeating group in a hidden popup. It is of type User. The source should be the Search for Users. Let’s call it var - search users

Then, in your Post search, make it so Created By is in var - search users List of Users.

This will do the search once and provide the list as a search constraint, rather than doing the same search every time.

1 Like

This is probably best route to go. It’s not as complex as you think it is. If you really want to solve it you could do a recursive workflow that goes through all the posts and edits them. Have a field ‘postVisibilityModifying’ yes/no. When the workflow kicks off, set it to yes. When it’s done, set it to no. Don’t allow the user to adjust the visibility if it’s set to yes.

There’s probably a better obvious solution I’ve missed…

This topic was automatically closed after 70 days. New replies are no longer allowed.