Best answer

Google Drive: Can you get parent of incoming files?

  • 7 July 2020
  • 2 replies
  • 343 views

I’m using the New File event to retrieve certain data from every new file and store them somewhere else.

The data I’d like to retrieve includes the parent folders the file is in. For example, I put a test file inside a folder inside another folder. I’d like to get the name of both these folders.

The data options I see only seem to retrieve the direct parent folder’s ID, which isn’t enough for me. Is there a piece of data I’m overlooking or is there simply no way to get all parents’ and their respective names?

Thank you very much in advance!

icon

Best answer by Danvers 10 July 2020, 14:24

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +12

Hi @Thacchi, welcome to the Community!

 

Unfortunately, there isn’t a straightforward way to do this. The New file trigger will only pull the folder ID of the folder that the file was in, not any parent folders. 

 

One way that you could workaround this would be to create a lookup table that finds the parent folder of the original folder based on the original folder’s ID. To do that, you’d put the folder ID of the original folder (the one that the New File is in) on the left hand side of the table and then the Parent folder (or folders) on the right:

 

If you take this route then when you add a new folder, you’ll need to add a row to the table.

Also, if you want more than the parent folder (eg you want the parent folder and that  folder’s parent folder all as separate fields, then you would be better off creating a Google Sheet as a lookup table. In column A put the original folder ID, then in the other columns put the various parent folders. Then, in the Zap, use a Google Sheets Lookup Spreadsheet Row action to search the sheet by the original folder ID, which will return all of the other columns (the parent folders) for that row. 

 

I hope that helps!

Thank you for the reply @Danvers! I’m afraid adding the folders manually won’t be doable. It’s quite unfortunate that a straightforward way isn’t currently possible.