How to check if a node was executed

Describe the problem/error/question

I’m trying to find the easiest way to check if a given node was executed or not. Since imagine having an IF statement that later converges again where sometimes it will only take the true path, the false path, or some cases both paths.

So I’m looking for a way to say if a given node in the true/false path executed, so I can output some extra data in a later node where it converged from both branches. is this possible?

I know I can do it by looking at all the IF nodes that will executed, and check their $(‘IF’).all(0).length > 0 returns items, but that is a bit cumbersome. Had a look at the inbuilt functions, but if the Node never ran, it throws an error.

I think what you are looking for is Merge Node.
This node continues only if received data from 2 sources.
Also be very that there is a bug in this node in versions prior 0.227 as described here and several other questions.
Just be sure to use output of second source, it works as intended.
But I’m not quite sure what exactly you are doing. If you can share your workflow, that would help.

1 Like

Sample below, but I’m using something like this where I can have multiple branches that do HTTP requests depending on the input.

This is of course a simplified version, some might have more branches, but the idea is that I report back in a Code Node of what each branch has done (IE the output of “Produce New Data Here” for instance). If this branch was not executed, it would return null for that JSON Object.

Like I mentioned I could use the IF statement here to check if it had any output, before trying to get the output of “Produce New Data Here”, but that gets a bit tedious if the upper or lower branches have more ifs.

I’m using this as a subworkflow, so I’d only want one object to be returned, something like

    "TopBranchResultIfRan": ...,
    "LowerBranchResultIfRan": ...

The problem I’d have with the Merge node is it would still execute both paths, and likely cause errors since it would be trying to execute it without input.

EDIT: I did just read the other thread regarding the Merge Node, and it seems I can use that once the new behaviour is added, this will be great! That should definitely solve it, and also solve the other problem where if both nodes execute, I get two results, as the flow gets executed twice.

1 Like

Glad to hear this will solve the problem for you. Not much longer now until this change goes live :slight_smile:

There’s also a number of additional changes which you might want to check out ahead of the upgrade, they are listed here in the docs.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.