Best practice to reference a node that could have not been executed

In some workflows I need to feed the ouput of more than one node into another one, but the input nodes aren’t executed every time.
Think for example of a workflow starting with two different triggers.
I don’t want to duplicate paths.

If I use the || notation, it throws an error because one of the nodes isn’t exectured. Can I solve this with a Merge node. Or is there a better practice?

Would the different node which might or might not execute return the same data structure?

One way is to use a Merge node and then just check which data inputs came in and continue from there

Thanks, that’s what I mentioned in my question.

Did the above suggestion solve your question?

And if the input nodes return a different structure?
Can I use the javascript question mark?
This notation worked a few times. $json.?functionname

With the solution above you should then be able to use || or ?? since the merge will handle which nodes executed, then it is just checking the data

when val1 is null it will use val2, else it will use val1

Just change the link of the IF

It’s not a super clean solution, else we could maybe use a code node as well

There is an expression function you can use to check if a node has executed.
Cannot find it right now as I am on my phone and connection is bad.
You should be able to find it though also on the forum there are some topics about it.

Yes, right. I read about it.
Is it a cleaner solution than using a merge node?

I think it is called {{ $('Node Name').isExecuted() }}, however the issue here is that you will still have 2 items meaning the node would execute twice, once for each of the incoming streams giving you a list. I reworked my solution to be a lot cleaner. If var1 executed the last set node will use that else var2 gets used

yeah that is it.
I only read the original question which was about 2 different triggers being used and wanting to check what trigger was the trigger for the workflow. Could have read it wrong though.

I am however interested in how the {{ $('Node Name').isExecuted() }} function could be used in a use case. In my last example, I did have to set the setting to always output a result from the Merge node to force it to continue.

I don’t understand the role of the Merge node in this case. You still refer to the var1 and var2 fields.

The purpose of the Merge in my example is to simply bring two different streams of node executions into a single output containing both variables at best or at least of of them, in this case var2 will always return and var1 is “optional” based on the if condition.

Then from here, it’s very simple to use the || operator to decide which variables to work with. The trick i am using is to avoid having to check whether a previous node actually ran or not and only deal with what variables are available by the time we need to decide where to get variable values from. Hope this makes sense. This is how I understood your original question