I am using 2 triggers in my workflow n8n form trigger and a webhook or scheduled trigger. The problem is whenever I initiate form trigger, workflow also activates webhook (with no data) or scheduled event trigger. Next node is a Switch node in which I want to write rules based on the triggering node, I tried {{ $prevNode.name }} but it is giving me name of the other trigger which I didnt initialise.
You can see in the attached picture that both the triggers are activated.
I would probably use an Edit Fields node to normalise the Form Trigger data so it matches what the webhook sends then use a noop to give a common reference if you need to refer back so an example of this could be like the below where we take the form and rename the fields to name and transaction and for transaction we use the first character either a B or an S.
Using CURL if we send a body containing a name and a transaction when the data comes through the Data noop node it will be the same so now in the workflow you can use {{ $('Data').first().json.transaction }} or {{ $('Data').first().json.name }} and it won’t matter which trigger started it the data will be the same.
First of all, thank you so much for your time and inputs.
The solution you are suggesting sounds more like a workaround to me. I will give it a try but dosent look right to me. My requirement is pretty simple, I want to identy which trigger started the workflow?
Is it not possible to identify that? We are officially supporting myultiple triggers per form and I am having hard time digesting this that there is no other way except merging and sanitising the data. Plus the another concern seems to be a bug where 1 trigger got fired but we can see green line flowing from both the triggers. Please clarify.
As each trigger should only run once you could use $("<node-name>").isExecuted to find out if a node has been run which should work for a trigger node but it will lead to a more complex workflow than the example approach.
I would always recommend sanitising the data as well so that you have a consistent reference point this will also ensure you have the data you are expecting and it will make it easier to maintain.
With the screenshot you posted I was not able to reproduce that but with the way n8n works a workflow can (or should) only be triggered by one trigger at a time. So you can have multiple in there but only the one will start it.
That is not working as both the triggers are getting executed i.e. form one and webhook one (without calling). Even after sanitising the data, the webhook one is getting triggered automatically with null data, i have tried this with multiple times and combinations in testing mode. Seems like a bug to me.
Can you give me an exapmple work flow with twi triggers 1 webhook and 1 form or on button click. and when form is submitted there is no feed from webhook node?
Oddly even if I add the snippet you previously provided I do not get the issue with both executing as a workflow should only be triggered by one trigger at a time.