I have a single select list in Airtable “typeBilan”.
How do I get the options directly from the database?
This case is simple, but I have other cases where there are more choices, and where more choices are likely to be added in the Airtable base. I want to sync those choices with WeWeb automatically.
@Joyce has shown a trick to do that in Build the WeWeb Public Roadmap - YouTube, but I feel like that trick falls short in a specific race condition: when no record contain a given option, this option will not show up in WeWeb.
The reason is that Joyce’s trick is to take a whole collection and do a “rollup” with
true which only keeps different values, essentially making it an array of different values.
But if there are no value in the collection (AKA no record with such option) then the options that aren’t listed will not yield a choice either.
How can we work around that limitation? Since the new Airtable API, I suspect it should be possible to access a field’s metadata, such as the options. But this integration isn’t available yet in WeWeb. (and I’m not sure it’s achievable manually, even using the raw REST API)
Also, in the event of using Joyce’s trick, isn’t it better to avoid duplicating the same collection and rather achieve the same using a Formula? I am concerned with performances and Airtable API rate limits.
I suspect duplicating the same collection will yield more HTTP requests, but it depends on how WeWeb is optimized. Does it blindly re-run the same network requests for each collection? Or does it have some optimization to avoid doing unnecessary calls?
P.S: For the sake of documentation, here is the Airtable API endpoint I think we could call, to get all the options of a given field: Airtable Web API