How can I select the correct set values after an if node? See attached image for example, but basically I am doing an IF check and want to use the SET path for my http client call. Any tips or tricks? I tried merge but none of the settings seemed to work and the whole execution would stop at the merge as if it was waiting for the other path to finish.
Right off the top of my head, I would say you can add an if condition in the expression. If you share the workflow, I might be able to help you better.
{
"nodes": [
{
"parameters": {
"conditions": {
"boolean": [],
"number": [
{
"value1": "={{Object.keys($json[\"cse\"][\"jira\"][\"accountid\"]).length}}",
"operation": "larger"
}
]
}
},
"name": "Check if CSE was found",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
2410,
230
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "jirapayload",
"value": "={\n\"serviceDeskId\": \"9\",\n\"requestTypeId\": \"94\",\n\"requestFieldValues\": {\n\"summary\": \"{{$node[\"Set Log Values Jira Issue Values\"].json[\"Summary\"]}}\",\n\"customfield_11639\": \"{{$node[\"Set Log Values Jira Issue Values\"].json[\"StartTime\"]}}\",\n\"customfield_11663\": \"{{$node[\"Get latest TC Version\"].json[\"Values\"]}}\",\n\"customfield_11660\": \"{{$node[\"Set Log Values Jira Issue Values\"].json[\"ClientURL\"]}}\"\n},\n\"raiseOnBehalfOf\": \"{{$node[\"Set Log Values Jira Issue Values\"].json[\"cse\"][\"jira\"][\"accountid\"]}}\",\n\"requestParticipants\": [\n\"{{$node[\"Set Log Values Jira Issue Values\"].json[\"csm\"][\"jira\"][\"accountid\"]}}\"\n]\n}"
}
]
},
"options": {}
},
"name": "Build Jira Request",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
2610,
150
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "jirapayload",
"value": "={\n\"serviceDeskId\": \"9\",\n\"requestTypeId\": \"94\",\n\"requestFieldValues\": {\n\"summary\": \"{{$node[\"Set Log Values Jira Issue Values\"].json[\"Summary\"]}}\",\n\"customfield_11639\": \"{{$node[\"Set Log Values Jira Issue Values\"].json[\"StartTime\"]}}\",\n\"customfield_11663\": \"{{$node[\"Get latest TC Version\"].json[\"Values\"]}}\",\n\"customfield_11660\": \"{{$node[\"Set Log Values Jira Issue Values\"].json[\"ClientURL\"]}}\"\n},\n\"raiseOnBehalfOf\": \"5e5e7effab90210c8de30f39\",\n\"requestParticipants\": [\n\"{{$node[\"Set Log Values Jira Issue Values\"].json[\"csm\"][\"jira\"][\"accountid\"]}}\"\n]\n}"
}
]
},
"options": {}
},
"name": "Build Jira Request for customer with no cse",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
2610,
310
]
},
{
"parameters": {
"authentication": "basicAuth",
"requestMethod": "POST",
"url": "=https://jira-tc.atlassian.net/rest/servicedeskapi/request",
"allowUnauthorizedCerts": true,
"jsonParameters": true,
"options": {
"bodyContentType": "json"
},
"bodyParametersJson": "={{$node[\"Build Jira Request\"].json[\"jirapayload\"]}}"
},
"name": "Submit Jira Ticket",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
2960,
230
],
"credentials": {
"httpBasicAuth": "Jira Angel Creds"
},
"disabled": true
}
],
"connections": {
"Check if CSE was found": {
"main": [
[
{
"node": "Build Jira Request",
"type": "main",
"index": 0
}
],
[
{
"node": "Build Jira Request for customer with no cse",
"type": "main",
"index": 0
}
]
]
},
"Build Jira Request": {
"main": [
[
{
"node": "Submit Jira Ticket",
"type": "main",
"index": 0
}
]
]
},
"Build Jira Request for customer with no cse": {
"main": [
[
{
"node": "Submit Jira Ticket",
"type": "main",
"index": 0
}
]
]
}
}
}
Just change this {{$node["Build Jira Request"].json["jirapayload"]}}
for {{$json["jirapayload"]}}
That’s what I thought as well but it does not seem to be working. Something about how I am merging the two streams doesn’t seem to pass the values along. I’ve tried keep only set on and off on the two branching nodes but just shows as not found for the value for the snippet you recommended.
If you run it, you will see it works.
I think the problem was that I was on an older version of n8n. I’ll have to try it again now that I’m on the latest version.