13
Views
2
Comments
What’s the best way to work with user settings?
Application Type
Reactive

Hi there.

In my application, the user has access to a settings screen, where they can change things about how the app works for them. I’m fairly new at this, so I was wondering: how do I work with user settings? I’m thinking I should have a settings entity where I store the preferences of each user, when they start the app I get their corresponding settings from the DB and then I store them in a Client Variable (that way I can use them every time I need to without having to consult the DB countless times).

Is this a good way to approach it? Am I missing something?

Any feedback would be appreciated :)

Rank: #299

Hi Yizuhi,

As far as you are doing this activity just to change the application's look and feel based on the user's choice, your approach looks good to me. Sometimes, hitting  database multiple time to perform different operations creates performance issue.  So, it is also a good idea to store it in Client variables to reduce the hits to database to get the setting values on every new screen they browse.

As per my experience with OS, I did not see any issue with your approach. However, it would be better to take some more feedback from other community members.

Thanks & Kind Regards,

Sachin

Rank: #54

Hi Yizuhi,


Depending on the type of data, you may not want to store them in client variables because they can be tempered and it is not secure. For instance, if you have a flag CanEdit or a role that may be changed by an attacker, or a password to access confidential data, you DO NOT want to have this information as a client variable.

In that case, you want to save them in the database.

You can read more about client variables and the above information in the OutSystems documentation here.



If it is a simple query you should not have a problem of performance. You also can decide to cache the query if the settings are rarely changed to avoid going to the database every time. You would need to invalidate cache when you change those settings. You can read about how caching works in OutSystems here.


Hope it helps.


Kind Regards,

João