从工作流的早期阶段检索链接项(Retrieve linked items from earlier in the workflow)#
节点输入数据中的每个项目都可以追溯到生成它所使用的前一个节点的项目。如果你需要检索比紧邻的前一个节点更早的关联项目,这会很有用。
🌐 Every item in a node's input data links back to the items used in previous nodes to generate it. This is useful if you need to retrieve linked items from further back than the immediate previous node.
要访问工作流程中先前链接的项目,请使用 ("<node-name>").itemMatching(currentNodeinputIndex)。
例如,考虑一个执行以下操作的工作流程:
🌐 For example, consider a workflow that does the following:
-
客户数据存储节点会生成示例数据:
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": "gatsby@west-egg.com", "notes": "Keeps asking about a green light??", "country": "US", "created": "1925-04-10" }, { "id": "23423533", "name": "José Arcadio Buendía", "email": "jab@macondo.co", "notes": "Lots of people named after him. Very confusing", "country": "CO", "created": "1967-05-05" }, ... ] -
“编辑字段”节点简化了以下数据:
1 2 3 4 5 6 7 8 9
[ { "name": "Jay Gatsby" }, { "name": "José Arcadio Buendía" }, ... ] -
代码节点会将电子邮件地址恢复给正确的人:
1 2 3 4 5 6 7 8 9 10 11
[ { "name": "Jay Gatsby", "restoreEmail": "gatsby@west-egg.com" }, { "name": "José Arcadio Buendía", "restoreEmail": "jab@macondo.co" }, ... ]
代码节点使用以下代码执行此操作:
🌐 The Code node does this using the following code:
=== “JavaScript”
1 2 3 4 5 6 | |
1 2 3 4 | |
您可以从 n8n 网站 | itemMatchin 使用示例 查看并下载示例工作流。
🌐 You can view and download the example workflow from n8n website | itemMatchin usage example .