Help

Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

Parent Child tree hierarchy

Topic Labels: Extensions
Solved
Jump to Solution
1187 5
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi… I’m looking for a scripting solution that lets me auto-populate a field with a parent and child relationship.
Eg -
Column 1 has the children
Column 2 has the parent of the child

Screen Shot 2021-11-03 at 12.51.14 PM

I’m wondering if I can write a script that can populate a new column with the tree hierarchy like this -

wco:WC Interface → wco:Area → wco:Block → wco:Image Card → wco:Hero Image Card

I have looked at a solution posted by joao_melo which works.
But i’m wondering if this is doable in a script?

1 Solution

Accepted Solutions

Here’s a link to the script. It uses the script settings features so you don’t have to mess with the code itself to set it up before running it.

Here’s a sample of the output (the {Label} field):

Screen Shot 2021-11-03 at 10.50.11 AM

You can pick any separator that you want, and also build labels based on hierarchy depth instead of the record name:

Screen Shot 2021-11-03 at 10.51.20 AM

See Solution in Thread

5 Replies 5

Welcome back to the community, @Anirudh_Subramaniam! :grinning_face_with_big_eyes: This is definitely doable via a script. In fact, I wrote a script a while ago that does this very thing. I thought that I’d shared it in the community already, but I can’t find it via a search. It needs a few quick updates to bring it up to spec, so I’ll reply in a few minutes once it’s ready.

Here’s a link to the script. It uses the script settings features so you don’t have to mess with the code itself to set it up before running it.

Here’s a sample of the output (the {Label} field):

Screen Shot 2021-11-03 at 10.50.11 AM

You can pick any separator that you want, and also build labels based on hierarchy depth instead of the record name:

Screen Shot 2021-11-03 at 10.51.20 AM

Thanks @Justin_Barrett. This looks amazing. I tried running it but I am getting the following error -

ERROR
Error: No field matching “Parent” found in table “Class”
at query.records.filter.record on line 63
at parse on line 62
at main on line 92

@Justin_Barrett - Nevermind. I fixed it… the code had the “Parent” field had coded. I changed it to linkfield and it worked. Thank you so much!

Sorry about that. I was in too much of a hurry and forgot about that one hard-coded field name. I changed it in the gist linked above, so anyone else grabbing it will be good to go.