Multi-Country Setup


I’m looking at setting up a system to manage data for users across multiple countries:

  • I thought of using locale to define country and language e.g. Russia could have English & Russian (ru_en, ru_ru)
  • Enabling the Cuba app locale settings, availableLocales & localeSelectVisible, to allow me to identify which country data (by proxy of the locale) the user is after

The questions I have are:

  1. How could I retrieve data from the entities, etc. based on locale selected (at login) by the user?
  2. Users may need access to multiple countries, so how could I setup the permissions to define locale access?

Or should I really be extending the User entity where the business rules, etc that I need are more naturally / easily configured? If so, are there any docs you could point me at to get started.


Hi Eddy,

  1. You can use UserSessionSource bean to obtain Locale of currently logged in user:

private UserSessionSource userSessionSource;
Locale locale = userSessionSource.getLocale();
  1. Could you describe in more detail what kind of access restrictions based on locale do you plan to use ?

For this task you can use access groups with constraints for User entity that use language property of user to limit row level access or you can extend User entity and add country attribute and use it in your row level conditions.

Hi Yuriy,

  1. Great, thanks for the tip, works well.

  2. The restrictions I’m looking at would be at the:
    a) record level based on the record’s country field e.g. user from USA would only see records with “country” field = USA. From what you’re saying access groups would fit this. Will give it a go.
    b) field level based on user country / locale e.g. a field “foobar” would only be visible to users from USA. From my brief readings, access groups should cover this too?

In fact you cannot hide/disable fields using access groups, because they are restrict only row level visibility / actions. You can full fill requirement b) using either additional Roles (by each country) or custom code in your screen that will simply hide/disable a field according to a user country.