Hi again! I’m still quite new here, but I was making good progress until I hit an issue with the If block that is driving me bonkers.
I’m trying to use an If block to match against a string evaluated from an expression. I can match data against a string literal without issue, but if I use an expression that produces the exact same string, it doesn’t match. What could I possibly be doing wrong here?
Thanks so much for your patience.
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"functionCode": "return [\n {\n json: {\n name: 'bar'\n }\n },\n {\n json: {\n name: 'foo'\n }\n }\n];"
},
"name": "Test Data",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
650,
300
]
},
{
"parameters": {
"functionCode": "return [\n {\n json: {\n name: 'foo'\n }\n }\n];"
},
"name": "Search Value",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
450,
300
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"name\"]}}",
"value2": "foo"
}
]
}
},
"name": "Literal Match",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
850,
400
],
"notesInFlow": true,
"notes": "Works"
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"name\"]}}",
"value2": "={{$node[\"Search Value\"].json[\"name\"]}}"
}
]
}
},
"name": "Expression Match",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
850,
200
],
"notesInFlow": true,
"notes": "Doesn't work"
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Search Value",
"type": "main",
"index": 0
}
]
]
},
"Test Data": {
"main": [
[
{
"node": "Literal Match",
"type": "main",
"index": 0
},
{
"node": "Expression Match",
"type": "main",
"index": 0
}
]
]
},
"Search Value": {
"main": [
[
{
"node": "Test Data",
"type": "main",
"index": 0
}
]
]
}
}
}