Retrieve linked items from earlier in the workflow#
ทุก item ในข้อมูล input ของ node จะเชื่อมโยงกลับไปยัง item ที่ใช้ใน node ก่อนหน้าเพื่อสร้างมันขึ้นมา สิ่งนี้มีประโยชน์หากคุณต้องการดึง item ที่เชื่อมโยงจาก node ที่อยู่ก่อนหน้ามากกว่า node ที่อยู่ติดกันทันที
ในการเข้าถึง item ที่เชื่อมโยงจาก node ก่อนหน้าใน workflow ให้ใช้ ("<node-name>").itemMatching(currentNodeinputIndex)
ตัวอย่างเช่น พิจารณา workflow ที่ทำสิ่งต่อไปนี้:
- The Customer Datastore node generates example data:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
[ { "id": "23423532", "name": "Jay Gatsby", "email": "[email protected]", "notes": "Keeps asking about a green light??", "country": "US", "created": "1925-04-10" }, { "id": "23423533", "name": "José Arcadio Buendía", "email": "[email protected]", "notes": "Lots of people named after him. Very confusing", "country": "CO", "created": "1967-05-05" }, ... ]
- The Edit Fields node simplifies this data:
1 2 3 4 5 6 7 8 9
[ { "name": "Jay Gatsby" }, { "name": "José Arcadio Buendía" }, ... ]
- The Code node restore the email address to the correct person:
1 2 3 4 5 6 7 8 9 10 11
[ { "name": "Jay Gatsby", "restoreEmail": "[email protected]" }, { "name": "José Arcadio Buendía", "restoreEmail": "[email protected]" }, ... ]
Code node ทำสิ่งนี้โดยใช้โค้ดต่อไปนี้:
1 2 3 4 |
|
1 2 3 4 |
|
คุณสามารถดูและดาวน์โหลด workflow ตัวอย่างได้จาก n8n website | itemMatchin usage example .