I'm trying to build a workflow that will loop through my environments (e.g. const envs = ['dev', 'stage', 'prod']) , update the current environment each loop, and then perform a resource query.
So for example, on the first loop, it will run the query for dev, then for stage, then for prod.
The idea is eventually I'll merge all of the data into a single result set and output to CSV.
Is this possible? I can't seem to figure out a way to dynamically set the current environment programatically.
I don't think you could do that - environments are typically (and I assume in Retool's case too) totally separate from each other. You aren't meant to connect to a dev database from prod, or anything like that.
What you might be able to try though, would be to set up a webhook for each environment and have the workflow respond with the data you want from the env. Then call each webhook from Prod, assemble the data, and do whatever you want with it.
Hey @melloyellow, I don't believe being able to programmatically change the retoolContext.environment is on the roadmap, but I've submitted the request for you. As you mentioned, the workaround would be to set each postgres db to it's own resource.
Is there a way to set the environment on startup. I want our users to go to the production environment regardless which one they had selected from before.