Use Case:
Today’s Date Function will generate the Date and with the help of MySQL Node, I’m getting the email address matching today’s date.
Actually, there are multiple emails, Not only one.
Then Updating the Contact with a Tag in Automizy Node.
The Problem is. It’s updating only the first data got from Database.
I want to loop through this and update all the emails in Automizy which I got from MySQL Node.
Output of MySQL node:
Workflow:
{
"nodes": [
{
"parameters": {
"triggerTimes": {
"item": [
{
"hour": 23,
"minute": 58
}
]
}
},
"name": "Cron",
"type": "n8n-nodes-base.cron",
"typeVersion": 1,
"position": [
590,
320
]
},
{
"parameters": {
"functionCode": "var today = new Date();\nvar dd = String(today.getDate()).padStart(2, '0');\nvar mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!\nvar yyyy = today.getFullYear();\n\ntoday = yyyy + '-' + mm + '-' + dd;\nitems[0].json.todayDate = today;\nreturn items;"
},
"name": "Today's Date",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
770,
320
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "=select email FROM api_key where erd=\"{{$node[\"Today's Date\"].json[\"todayDate\"]}}\""
},
"name": "MySQL1",
"type": "n8n-nodes-base.mySql",
"typeVersion": 1,
"position": [
950,
320
],
"credentials": {
"mySql": "Singapore DB"
}
},
{
"parameters": {
"batchSize": 1,
"options": {
"reset": true
}
},
"name": "SplitInBatches",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
1130,
320
]
},
{
"parameters": {
"operation": "update",
"email": "={{$node[\"SplitInBatches\"].json[\"email\"]}}",
"updateFields": {
"tags": [
"For Renewal"
]
}
},
"name": "Automizy",
"type": "n8n-nodes-base.automizy",
"typeVersion": 1,
"position": [
1290,
320
],
"credentials": {
"automizyApi": "Personalizery Automizy"
}
}
],
"connections": {
"Cron": {
"main": [
[
{
"node": "Today's Date",
"type": "main",
"index": 0
}
]
]
},
"Today's Date": {
"main": [
[
{
"node": "MySQL1",
"type": "main",
"index": 0
}
]
]
},
"MySQL1": {
"main": [
[
{
"node": "SplitInBatches",
"type": "main",
"index": 0
}
]
]
},
"SplitInBatches": {
"main": [
[
{
"node": "Automizy",
"type": "main",
"index": 0
}
]
]
}
}
}