andness
andness12mo 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
rubenf12mo 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
andnessOP12mo 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
rubenf12mo ago
Did you whitelist them in Whitelist_envs ?
andness
andnessOP12mo 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
rubenf12mo ago
👍
andness
andnessOP12mo 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
rubenf12mo ago
Yes
andness
andnessOP12mo ago
Ok, that's good to know.