Add global variables to workflows

I often have to do weird workflows in situations where I would normally use a variable with a conditional assignment. variables, like the ones in apps and modules would help simplify these parts of workflows. usually I just connect a bunch of blocks to 1 JS block named 'normalizeData' and use if/elses to return the object i want from whatever sources I connected. this way later on I can reference one block instead of using conditionals everywhere to select the .data from the correct block.

2 Likes

Hi @bobthebear, we found and existing internal FR for this. I added your +1 and feedback to it.
We'll update you here when there are any updates on it. :slightly_smiling_face:

1 Like

For now, what you are doing is the workaround. Here is another example for visualization, in case other users are looking for an implementation:

1 Like

Hi @Paulo plus one for this please!

In my situation, I want to store a JWT in a variable to be used in a loop that makes api calls. However, the token expires before the loop is finished, so I'd like to be able to check the expiry within the loop and if it's close to expiry, request a new token and update the variable.

If you think there's already a way to do this, I'd be grateful for advice!

Hi @paul_mcardle! I added your plus one. :slightly_smiling_face:
On the meantime, we should be able to return the index (and data at the index) where the error happened. Using an error handler, we could get a new token and begin a new iteration starting at the index we returned.

@Paulo I am struggling to figure out how I can do this, and alter the value of the "variable" within the workflow. Using your example above, I am tempted to do something in query1 like set code1.data.test2 = false based on something it checks, and have subsequent code blocks now read that variable as code.data.test2 == false.

When I try that, it works within the scope of the current block. But anything after the current block goes back to the original value.

codeBlock.data is read-only, this is why code1.data.test2 = false is failing silently. It doesn't change the value. What I meant was to reference code1.data.test2 (index returned) on an error handler or another block with the goal of running a new loop, using the index to reference where to start.

However, @explore recently shared a way to trigger Workflows recursively. Maybe this is an easier implementation for your use case:

Feel free to share a screenshot of your WF, it would help us figure out the next steps. :slightly_smiling_face:

1 Like