Choosing between 2 input items when one node is not executed

I am trying to create a workflow that starts with 2 triggers:

  • manual run or whatever
  • webhook run

when I execute webhook trigger everything works fine, but when I use the second trigger it gives me an error that referenced node is unexecuted. I tried finding answers in other topics but I still cannot figure it out. I’m noob in n8n, sorry if I am asking stupid questions.

I tried writing a javascript inside ChoseProjectId node to dynamically identify the projectId

Please share your workflow

Share the output returned by the last node

Referenced node is unexecuted

An expression references the node ‘Webhook’, but it hasn’t been executed yet. Either change the expression, or re-wire your workflow to make sure that node executes first. I expect node ChooseProjectId always return projectId based on the trigger

Information on your n8n setup

  • n8n 1.90 Cloud
1 Like

I have had some success using a ternary operator combined with the isExecuted attribute of a previous node.

{{ $('SetDataManually').isExecuted ? $('SetDataManually').item.json.projectId : $('Webhook').item.json.params.projectId }}
  • Note: This might report a “Referenced node doesn’t exist” error in some scenarios for test mode, but should work if you run the workflow from the start trigger’s Test Workflow button.
  • Note: You might need to reverse which node you check for isExecuted, so also try {{ $('Webhook').isExecuted ? $('Webhook').item. ... : $('SetDataManually').item. ... }}

Alternative Way

Make the When Clicking 'Test workflow' a completely separate flow that ends with an HTTP Request node that calls the test webhook endpoint (using http://localhost:5678/webhook-test/...) the same way a client would once you activate the workflow.

3 Likes

Hi @Evgen_Sazonov,

Since there are different field names coming from the webhook and the test workflow, you’ll need to add something like a switch statement to account for the name differences.

Try this workflow.

1 Like

Thanks you!
I was trying to achieve a single projectId value in any of the nodes that I can use in all the following nodes.

I added a Merge node with Append and it seems to solve my problem

Thanks everyone for your help!

2 Likes

@Evgen_Sazonov

Glad you got it to work!

1 Like

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