How To Link Records In Airtable

Sometimes when new records are created, you might want to link new records to old records. This is exactly what I explain in this article. You will learn how to automatically link a new record to an old record from another table. To explain this, we will walk through the example of a school base. In this base, we would like to connect each new student created with a teacher, basically assigning each teacher to a student. Let's learn how to Link Records Automatically in Airtable.

Here we have two tables as follows:

  1. Teachers table
  2. Students table

To keep everything simple and easy to understand, I have kept minimum fields in both tables. Let's see what we currently have in both tables.

Teacher's Table

airtable linked records airtable link to another record how to link records in airtable linked records airtable linking records in airtable link to another record airtable airtable link records across bases airtable linked fields airtable script airtable automation

As you can see in the image above, in the teacher's table we have the following fields:

  1. Name: Name of teacher
  2. Class: Teacher's teaching class
  3. Max Students Allowed: How many max students can be assigned to a particular teacher
  4. Students: Linked to students records
  5. createdTime: Time on which record was created

Student's Table

airtable linked records airtable link to another record how to link records in airtable linked records airtable linking records in airtable link to another record airtable airtable link records across bases airtable linked fields airtable script airtable automation

As you can see in the image of the Student's table we have:

  1. Name: Student's name
  2. Age: Age of student
  3. Teacher: Assigned teacher

Logic or condition for assigning teacher to student

For this example, our logic is very simple, as described below:

  • If a student's age is 5 years, then we assign a standard or class 1 teacher.
  • If a student age is 6 years then we assign a standard or class 2 teacher.
  • and so on...

Implementation of the automation

In order to implement the automation, you need a premium subscription for Airtable. If you already have one, you are good to go. Now let's follow the steps one by one and implement the automation:

  1. Click on the automation icon on the right side and choose: 'Create a custom automation'.
  2. Set 'When a record is created' as trigger of the automation and select the Student's table.
  3. Select 'Run a script' as action of the automation.
  4. Configure input variables as shown in the image below

airtable linked records airtable link to another record how to link records in airtable linked records airtable linking records in airtable link to another record airtable airtable link records across bases airtable linked fields airtable script airtable automation

Here in configuration we are basically selecting the last created record's data.

Step 5: Now get the code by clicking here and paste it in the script section.

Let's understand what the script is doing here:

  • The script is getting the last inserted data in the teacher's data.
  • Based on the logic that i explained before, it finds the teacher.
  • Then it simply updates the student's record with the teacher's id.

That's all you have to do. Now whenever a new record is created for students, a teacher will be automatically assigned to the student. You can use this kind of automation logic in many different ways, depending upon your needs. Fell free to contact me for a free Airtable consultation by Clicking Here

monino solutions logo

COPYRIGHT © 2024 Monino Solutions.