从工作流的早期阶段检索链接项#
¥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) 角色。
¥To access the linked items from earlier in the workflow, use ("<node-name>").itemMatching(currentNodeinputIndex).
例如,考虑一个执行以下操作的工作流程:
¥For example, consider a workflow that does the following:
- 客户数据存储节点会生成示例数据:
¥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 | |
¥The Edit Fields node simplifies this data:
1 2 3 4 5 6 7 8 9 | |
¥The Code node restore the email address to the correct person:
1 2 3 4 5 6 7 8 9 10 11 | |
代码节点使用以下代码执行此操作:
¥The Code node does this using the following code:
1 2 3 4 | |
```python for i,item in enumerate(input.all()): _input.all()[i].json.restoreEmail = ('Customer Datastore (n8n training)').itemMatching(i).json.email
return _input.all();
```
你可以从 n8n 网站 | itemMatchin 使用示例 查看并下载示例工作流。
¥You can view and download the example workflow from n8n website | itemMatchin usage example .