Where to put global config objects

Hi all,

so we have some enums (usually for option lists) coming from our DB that need translations/mapping in the UI. Whats the best practice for that?

I currently use a kind of config object in an app variable that looks like this eg:

[
  {
    "value": "ENUM1",
    "label": "Translation 1",
    "color": "blue"
  },
  {
    "value": "ENUM2",
    "label": "Translation 2",
    "color": "green"
  },
  {
    "value": "ENUM3",
    "label": "Translation 3",
    "color": "orange"
  }
]

But I will need this in several places. Even disconnected apps. I tried putting it in a retool config variable in the Settings, but this messes up the object (gets injected as a string in the app, with linebreaks and all).

Ideas? Best practices? How is l10n suppose to work anyway? :slight_smile:

Thx!

Ok, for now I put it in Settings->Advanced->Preloaded Javascript. I suppose this will get crowded and confusing after some time. But for now it works.

Config Var

so if you want to use the retool config variable, as you noticed it only accepts strings, so you would need to use JSON.stringify(your_obj) then take the result and store that in the config variable. when you need to use it you would use JSON.parse(your_retool_config_var) which gives you the original JSON object.

Preloaded JS

preloaded Javascript would work as well, the down side here is that in every project you need this JSON you'll have to add it to settings->advanced->proladed js and if you need to make a change you would then need to remember every project it's in and make the change to each of them.

User Attributes

if you have the Business or Enterprise plans you could put it in a user attribute:
image
this would be default for all users and it could be updated per user (like having app settings per user)

Query Library

since you said the enums are coming from your DB, the better option might be to use the query library and make a query named Get DB Option List which returns your json object. this way the query can be used in EVERY project and if any changes need to be made, they only have to be made in 1 place.

1 Like