andness
andness13mo ago

How can I use a context variable in a branch predicate?

I'm trying to use a context variable in a branch predicate, but I can't figure out the right syntax. The documentation on flow inputs has some examples (see picture), but none of them work. What I'm trying to achieve is to run one part of the workflow only if an environment variable has a specific value. Is there some documentation on what expressions are possible in the branch predicates (and flow inputs, I guess they use the same javascript evaluation?)
8 Replies
rubenf
rubenf13mo ago
all that is available as context should be accessible from the right panel of the expression editor i'm speaking of the panel here: you can use results.X and flow_input.Y or variables(X) or resources(Y)
andness
andnessOP13mo ago
I suspect I'm confused by the word context, because in the variables tab there's also "Contextual" variables, which you reach through the environment. In my case it's called NDAP_ENV and indicates if we're running in prod or not. As a workaround I've created a simple inline step that pulls out the value using os.environ.get("...")
rubenf
rubenf13mo ago
Did you whitelist them in Whitelist_envs ?
andness
andnessOP13mo ago
Yes, as an environment variable it's working fine. So using a inline steps that pulls it out and returns it work, as I can then access is as a result value
rubenf
rubenf13mo ago
👍
andness
andnessOP13mo ago
So the branch predicates and other expressions in the flow editor are limited to what I can see in the right hand here?
rubenf
rubenf13mo ago
Yes
andness
andnessOP13mo ago
Ok, that's good to know.

Did you find this page helpful?