The Switch node takes input of a previous Webhook node, thus its output contains is an one-item array where the “body” of the HTTP request is nested inside another JSON.
From the Switch node, get {{ $json.body.data.id }}, find out if this value exists in {{ ID2 }} of the getAll node.
In the pictures shown above, the {{ $json.body.data.id }} is 14, and the {{ ID2 }} is an array consisting of number from 1 to 12. So the output if false.
Based on your example data it seems to me you can just remove the Switch1 node, as all its output branches are sent to the same subsequent node anyway. Or in other words, your Switch1 node might send data to output 0, 1, 2, or 3 but for the workflow it doesn’t make a difference.
With your subsequent Merge node you are, however, on the right track as the Merge node lets you compare two separate input branches using the Combine → Keep Matches and Combine Keep Non-Matches operation. Here’s a quick example showing the idea using simplified example data:
When running this example with an id value in the webhook that’s not part of your Grist list, the item would reach the bottom branch:
Thank you very much for the reply! Your workflow works like magic.
There is still one problem, though. The switch node doesn’t work quite like the set node, which outputs one array at most. Current merge branch seems to only take the first branch of the switch node (in my case ‘0’). So if the input value falls into another branch, the merge node won’t pick up the data. You can replicate this problem by adding a mock switch node and set the output to a non-zero value. I’m not sure whether this is by design or a bug.
The switch node doesn’t work quite like the set node, which outputs one array at most. Current merge branch seems to only take the first branch of the switch node (in my case ‘0’).
From looking at your workflow it seems the Switch node serves no purpose since all items it returns are passed on to the same node anyway, regardless of their output.
Perhaps you want to simply add your Switch node after the Merge nodes to avoid this? The example Merge nodes I have provided will return the webhook item anyway, so you can still apply your Switch logic at a later stage.