We’re improving the Code node and many community members asked for the possibility to drag/drop data from the input panel.
The default mode for the code node is “Run Once for All Items”, which means that the code field has access to the whole array of items rather than iterating on a single item (docs).
What do you expect to happen when you drag an input data field in that mode?
Well done. It would be grant to have a UI node builder, and/or to group several nodes into a single one, and/or to make a node out of a code node. Thanks so much
My expectation, or hope, would be that it gives me a reference to that object/variable in the code the way the code block needs it referenced wherever I drop it - the way it does in other ‘expression’ fields.
Alternatively, giving us add-able fields above/below the code box to add input variables to - from the input json from previous nodes - and being able to reference those in the code with a specified label. The field you add could either have hard coded reference values (a, b, c, in1, in2, in3… whatever), or you could give us the ability to actually put in a name for that variable that’s referenceable in the code block.
I really like the way Gumloop handled this: Gumloop Code Node - Album on Imgur
Clearly this differs from the way N8N inputs work since you don’t have each input assigned to a nodule on the outside of the node, but in principle it would be similar. You could click ‘add input value/variable’ which would then give you a new field with a key:value pair. The Key would be hard coded or modifiable, whatever works, and be referenceable in the code. The Value field would be a normal N8N node field where you can write values or drag and drop input values as their json evaluation in ‘expression’ mode.
This is something I would REALLY like to see implemented, and wrote a feature request for it. Please feel free to PM me if I could be more clear about any part of the above description.
Thanks for ask and thanks for this wonderfull software.
If there were a way for a variable from a node to be visible in all nodes without needing to reference the node where it was created, that would be great.
A way to make a variable global in a workflow, only in the workflow and only at the time of execution.
For example, in a workflow I have a scheduling node and then one for checking Outlook emails. The data from the scheduling node does not go to the node after the scheduling node. So either I have to say that it is from the schedule node, which I sometimes can’t do, or I have to do a merge so that all the data arrives at the node after the outlook node.
If the variables were global throughout the workflow, this would not be necessary.