So I’m using the set variables node quite a bit atm so if I change anything in the JS of my previous nodes I only need to change referencing stuff in one place rather than a bunch of other places so that’s handy. But when I’m testing and I try to pull in the data from one of the tests when I’m testing a single node - setvariables isn’t setting the variables.
For example I have the variable taskPhaseName set in a previous setvariables node:
I run that setvariables node with the run node once button which in all other instances loads those variables into the chain for me to pull through for testing in later nodes
But unless I run the entire scenario once (which means it sometimes won’t go down the correct chain to the node I’m wanting to test because of the filters) those variables aren’t stored and it gives me null:
Potentially I’m doing wrong, or it just hasn’t been configured for this to work this way. In which case this post turns into a feature request.
Hi! If you’re getting a null value somewhere, it’s likely because you’re trying to access data that hasn’t been processed due to filters blocking further execution of the scenario. You’re probably trying to use a variable from a branch that wasn’t executed, right? In that case, it makes sense that you’d get null.
If those data are important to you, adjust the filtering logic so that the necessary data are always processed, and null won’t appear anymore. Or, if you’re bothered by the null value itself (especially if it’s being recorded or passed along), you can set up the filtering to display null simply as an empty row.
The SetVariable node creates a variable that is only available within a single execution. If you click “Run node once,” the variable is created in that execution. If you then click “Run node once” on the next node, that is a new execution. This is how it works. To make a variable available between executions, you can use SetGlobalVariables or Storage, which is a database.
Can I ask as a feature request for it to be set when I run the node once on the set variables in the same way that output data from a node that has been run once is available for me to use when testing? Otherwise it means I can’t really do any tests with the setvariables node unless I run an entire chain (which A) is a lot slower takes 20 or so seconds for the whole chain to run each test and B) there are often a bunch of nodes I don’t want to run when testing because they write data to places). I’ll record a loom to show you what I mean.
There is a possible workaround. You have two options to get data from SetVariable node:
Get it from tab “variables” in helper window (like you do now). In this case “run node once” on a previous node is not an option
Get var value from “data” tab in helper window from the node’s “SetVariable” results. In this case “run node once” should works the same way as with any other node.
Yeah that’s what I’ve been doing in the meantime. Just means if I have another set variables that overwrites a previous variable later on it won’t pull through (I haven’t actually tried that to see if it works yet, but it was an idea I had)
Meaning I can’t use any setvariable item unless I reference the node number specifically in any of the Toggl integrations. I have taken to just writing the JS nodes from scratch with a post request using their API because it’s the only way I can get it working.
Are the variables not being removed even after refreshing the page? It’s possible that the data is cached.
Regarding the error when substituting the variable, please send me a link to the scenario from the execution history where this issue occurs at [email protected].
Nah the variables are still there from however many days ago we were talking about testing the conditions with the setvariables node. Have defos refreshed the page multiple times and am many versions on from when I originally created those tests.
As a feature request - it’d be great if there was more reporting on filters in the same way that runs have reporting (ie input, output, log etc). Zapier has a whole node that does the filtering stuff so it shows all the logic it has for every run in the history.