n8n
Workflow
Using The Merge Node Merge By Key
This n8n workflow automates tasks and integrates with various services. Using The Merge Node Merge By Key - ready to import and run in your n8n instance.
n8n
workflow.json
About This Script
This n8n workflow automates tasks and integrates with various services. Using The Merge Node Merge By Key - ready to import and run in your n8n instance.
Features:
- Custom JavaScript function processing
Source Code
{
"nodes": [
{
"name": "Data 1",
"type": "n8n-nodes-base.function",
"position": [
602,
350
],
"parameters": {
"functionCode": "items[0].json = {\n\"data\": [\n{\n\"pointer\": \"12345\",\n\"panel\": \"234234\",\n\"subject\": \"Blah Blah\",\n\"note\": \"\",\n\"interviewers\": [\n{\n\"id\": \"111222333\",\n\"name\": \"Bobby Johnson\",\n\"email\": \"bobbyj@example.com\"\n}\n],\n\"timezone\": \"America/Los_Angeles\",\n},\n{\n\"pointer\": \"98754\",\n\"panel\": \"3243234\",\n\"subject\": \"Yadda Yadda\",\n\"note\": \"\",\n\"interviewers\": [\n{\n\"id\": \"444555666\",\n\"name\": \"Billy Johnson\",\n\"email\": \"billyj@example.com\"\n}\n],\n\"timezone\": \"America/Los_Angeles\",\n},\n],\n\"hasNext\": false\n};\nreturn items;\n"
},
"typeVersion": 1,
"id": "71701dd6-2d2b-4007-b408-6682d5b6c291"
},
{
"name": "Data 2",
"type": "n8n-nodes-base.function",
"position": [
602,
550
],
"parameters": {
"functionCode": "items[0].json = [\n{\n\"name\": \"test\",\n\"fields\": {\n\"FirstName\": \"Bobby\",\n\"LastName\": \"Johnson\",\n\"JobTitleDescription\": \"Recruiter\",\n\"HomeDepartmentDescription\": \"Recruiting Team\",\n\"Photo\": [\n{\n\"x\": \"attPuc6gAIHUOHjsY\",\n\"url\": \"http://urlto.com/BobbyPhoto.jpg\",\n\"filename\": \"photo.jpg\",\n\"size\": 28956,\n\"type\": \"image/jpeg\"\n}\n],\n\"eid\": \"111222333\"\n},\n\"createdTime\": \"2019-09-23T04:06:48.000Z\"\n},\n{\n\"name\": \"test2\",\n\"fields\": {\n\"FirstName\": \"Billy\",\n\"LastName\": \"Johnson\",\n\"JobTitleDescription\": \"CEO\",\n\"HomeDepartmentDescription\": \"Boss Team\",\n\"Photo\": [\n{\n\"x\": \"attPuc6gAIHUOHjsY\",\n\"url\": \"http://urlto.com/BillyPhoto.jpg\",\n\"filename\": \"photo.jpg\",\n\"size\": 28956,\n\"type\": \"image/jpeg\"\n}\n],\n\"eid\": \"444555666\"\n},\n\"createdTime\": \"2019-09-23T04:06:48.000Z\"\n}\n,\n{\n\"name\": \"test3\",\n\"fields\": {\n\"FirstName\": \"Susan\",\n\"LastName\": \"Smith\",\n\"JobTitleDescription\": \"CFO\",\n\"HomeDepartmentDescription\": \"Boss Team\",\n\"Photo\": [\n{\n\"x\": \"attPuc6gAIHUOHjsY\",\n\"url\": \"http://urlto.com/SusanPhoto.jpg\",\n\"filename\": \"photo.jpg\",\n\"size\": 28956,\n\"type\": \"image/jpeg\"\n}\n],\n\"eid\": \"777888999\"\n},\n\"createdTime\": \"2019-09-23T04:06:48.000Z\"\n}\n];\nreturn items;"
},
"typeVersion": 1,
"id": "65a255d6-e238-4f30-922b-e45aa4750bd4"
},
{
"name": "Convert Data 1",
"type": "n8n-nodes-base.function",
"position": [
752,
350
],
"parameters": {
"functionCode": "const newItems = [];\n\nfor (const item of items[0].json.data) {\n newItems.push({ json: item });\n}\n\nreturn newItems;"
},
"typeVersion": 1,
"id": "9a3f0367-d00d-435a-9c6a-4e1cab276fac"
},
{
"name": "Convert Data 2",
"type": "n8n-nodes-base.function",
"position": [
752,
550
],
"parameters": {
"functionCode": "const newItems = [];\n\nfor (const item of items[0].json) {\n newItems.push({ json: item });\n}\n\nreturn newItems;"
},
"typeVersion": 1,
"id": "c84a7deb-8c66-4cce-b27e-62171ad7e66c"
},
{
"name": "Merge",
"type": "n8n-nodes-base.merge",
"position": [
990,
430
],
"parameters": {
"mode": "mergeByKey",
"propertyName1": "interviewers[0].id",
"propertyName2": "fields.eid"
},
"typeVersion": 1,
"id": "1717a746-e633-4587-893f-8910bc7c8a28"
}
],
"connections": {
"Data 1": {
"main": [
[
{
"node": "Convert Data 1",
"type": "main",
"index": 0
}
]
]
},
"Data 2": {
"main": [
[
{
"node": "Convert Data 2",
"type": "main",
"index": 0
}
]
]
},
"Convert Data 1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Convert Data 2": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
}
},
"n8n_version": "1.5.0"
}
Requirements
n8n instance, API credentials for connected services
Tags
#n8n
#automation
#workflow