Google Drive Search loses item context

Describe the problem/error/question

Block: Load folders from Google Drive
Input: 1 item, folder id
Output: 2 items

Block: Load files from Google Drive
Input: 2 items, folder id loaded previously
Output: 3 items (from different folders)

Problem: The output items do not contain ids of the respective folders.

Attempt 1: Use “Edit Fields” with “{{ $(‘List Folders’).item.json.name }}”.
Problem: Context connection between the input and output items is lost. Error message: “An expression here won’t work because it uses .item and n8n can’t figure out the matching item. This is because the node ‘Google Drive’ returned incorrect matching information (for item 0 of run 0).”

Attempt 2: Find a checkbox “pass inputs as outputs” in a “Google Drive search” node.
Problem: No such feature.

Challenge

Any ideas, how to inject a folder id into a file item?

Please share your workflow

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hi @Pavel_Koryagin

Welcome to the community! You’re able to get this by adding all fields on that second file search and get the parents that references the folder where a file is at:

Hope this helps

Thanks, but in multi-user envs, there are often appear multiple parents per single file in GDrive (thus, the parents field is an array), so this would require some heuristics algorithm to identify the relevant one.

Additionally, I’m looking for a direct way to match a piece of data from the preceding steps. In the real case, it was parent and some other fields too (what I’ve shared is the reduced case.)

I see what you mean. Perhaps google offers a way to get this info via API so you can use the http node in your workflow?

Some APIs have a parameter like custom that they add to the response. I have no idea does GDrive have one.

I’ve implemented the part where I needed this as a separate service (out of n8n). The n8n-sytle no-code solution has not been found.