search my table in google sheet to find that I have that generated id or not by google sheet" node.
if there isn’t that id I create new row with that random id.
my problem is:
after search my table in google sheet (by lookout in google sheet node) how can I use null output in “if” node.
How can I use something like this:
if search results = 0 then true
Update:
I think One Option is add “empty” and “not empty” in string in “if” node.
I have the following: {{!!Object.keys($node["Get User"].data).length}}
where Get User, is a MySQL query that returns 0 rows.
On the Result (UI) it always says [not found]. Indead, if the query returns no results, the attribute data does not get created. Is there a way to check if data attribute exists?
Or, what’s the best solution to test if no rows where returned?
If the MySQL query does not return any rows the node after it does not executed as nodes only get executed if there is data. If you want that the next node does get executed no matter what, you can activate the option “Always Output Data” under the “Nodes” tab (next to the “Parameters” tab). Then it will make sure that at least always an empty object does get returned. Then also the above expression should work again.
I test n8n which I find very good.
I want to create a workflow to search if a value exists in my google sheets (I use lookup) and if so, do nothing, otherwise add the value.
I have a problem with the “if” function. If I activate the option “always output data”, and put {{!!Object.keys($node["Google Sheets"].data).length}} into value 1, only the true branch is always activated.
In the IF node, you can select the branch for which you want to see the output. By default, it displays the output for the true branch. You can change it to false by select false from the Output dropdown list on the top of the node.
If the value didn’t exist in google sheets, IF result is “not found” and no nod is executed.
If I check “always output data” it is the true branch wich is executed.
How does your IF-Node look like? Can you please post a screenshot.
In this case, you should not set “Always Output Data”. As it does exactly what you describe. It will always output data to the true-branch if there is nothing for the false one. As that is not helpful in this case, there is no need to set it.
Here an example workflow with the data from the Google Sheets node mocked:
To test how it would work if data would be found you can simply remove the // in the Function-Node.
Having now looked into what you want to do some more you would have to activate the option “Always Output Data” but not on the IF-Node, you have to activate it on the Google Sheets node. Because if you do not set it, and no value would be found the execution would stop at the Google Sheets Node.
Thank you very much, its works, even without node function.
To be sure I understand, when value don’t exists in google sheet, outbut data is empty, and IF node test if google sheets node has data?