Object Filtering Based on Conditions

Hi n8n Community! :wave:

Here’s the idea: given a node with N inputs, the new node would return one of these inputs only if certain conditions are met. For example, in my case, I need the node to return an input only if all inputs are not null. This would be super handy for managing scenarios with multiple conditions, like the simplified example I mentioned.

This feature would enhance the flexibility and efficiency of workflows, especially when dealing with complex conditional logic.

  • n8n version: 1.88.0
  • Running n8n via: Docker

I’ve tried many different solution but the best so far is having a merge node with this SQL query (the merge node has 5 inputs, but you can easily adapt the code for a different number of inputs):

SELECT CASE 
  WHEN (input1 IS NOT NULL 
    AND input2 IS NOT NULL 
    AND input3 IS NOT NULL 
    AND input4 IS NOT NULL 
    AND input5 IS NOT NULL) 
  THEN input1.* 
  ELSE {{null}}
END AS result
FROM input1
LIMIT 1

And attached having an “if” node that checks if the result is an empty array (I have not found a way to not return anything if the condition is not satisfied)