Skip to main content

Automatically Populate Junction Tables!

  • March 10, 2020
  • 27 replies
  • 375 views

Show first post
This topic has been closed for replies.

27 replies

Forum|alt.badge.img+5
  • Inspiring
  • July 18, 2024

Great question! For me it mostly has to do with usability. In this example, one person - say a project manager, is outlining all the high-level information about the project including key dates, and which companies should be involved. I envision the project manager using the script to create those junction records where another contributor to the team can easily find where they should be inputting data.

So yes while you are maintaining two many-to-many relationships with the script, it’s mainly about when/how you’re inputting the information. Would love your thoughts on this as well.


I know this was forever ago, I apologize. I'm trying to use this script, but the example base no longer gives access (or maybe I was supposed to request access manually?) Either way, my main question is about this add-on to the bottom of the script.

in this line:
let nonMatches = joinRecordsTwo.filter(c => !c.getCellValueAsString('Project Lookup').split(', ').includes(c.getCellValueAsString('Company')))

It looks like "Project Lookup" is a column added to the junction table. How do I do that so that it works properly? What am I looking up that allows the script to check for changes? 


Forum|alt.badge.img+5
  • Inspiring
  • August 22, 2024

I know this was forever ago, I apologize. I'm trying to use this script, but the example base no longer gives access (or maybe I was supposed to request access manually?) Either way, my main question is about this add-on to the bottom of the script.

in this line:
let nonMatches = joinRecordsTwo.filter(c => !c.getCellValueAsString('Project Lookup').split(', ').includes(c.getCellValueAsString('Company')))

It looks like "Project Lookup" is a column added to the junction table. How do I do that so that it works properly? What am I looking up that allows the script to check for changes? 


Answering my own question if anyone gets this far. This was the only part of the code that was missing some comments to help beginners understand.

The addition to the script is to provide a one-way sync update to your new junction table from one of the original tables. If, in your Company table, you delete a Project linking record in your Projects field, this piece of the script would delete the corresponding record of that Company/Project pair. It doesn't do the reverse, so if you ran this script again on the same tables, it would just recreate it.

In this case, (watch how many times I can say lookup in one sentence) you would create a lookup field in your junction table called "Project Lookup" that looks up the Company link record field from your Project table. This is where I got confused - I would have called this "Company Lookup", since the values would be Company links, not Project links - and the default name in Airtable would be "Companies (from Projects)". So this filter will compare the list of all Companies linked to this record's Project, and the Company that is explicetly linked in this record by the previous script. If the Company is missing, you must have deleted that link in the Companies or Projects table, so it will delete the record here.