Help

The Community will be undergoing maintenance from Friday February 21 - Friday, February 28 and will be "read only" during this time. To learn more, check out our Announcements blog post.

Segmenting a base into a master email list.

Topic Labels: Automations
522 7
cancel
Showing results for 
Search instead for 
Did you mean: 
p_finder25
4 - Data Explorer
4 - Data Explorer

Hey there - 

What I'm Trying to Accomplish:

I'm building an Airtable automation that extracts email addresses from multiple fields in my Contacts table and creates individual records in a Master Email List table. Each email should be stored as a separate record, along with the corresponding Contact Name and an "Email Type" field (Primary, Partner, Referral, or Connection).

This will allow me to export clean, deduplicated email data into HubSpot for email campaigns.

My Setup:

  • Table: Contacts (source table)

    • Fields:
      • Contact Name
      • First Name
      • Last Name
      • Email (Primary Email)
      • Partner Email
      • Referral Email
      • Connection Email
  • Table: Master Email List (destination table)

    • Fields:
      • Email
      • Contact Name
      • Email Type (Primary, Partner, Referral, Connection)

Automation Steps (Attempted):

1️⃣ Trigger: "When a Record Matches Conditions"

  • If any of the email fields (Primary, Partner, Referral, or Connection) is not empty, trigger the automation.

2️⃣ Find Records Action:

  • Find all records in Contacts where Email, Partner Email, Referral Email, or Connection Email is not empty.

3️⃣ Repeat for Each (Loop):

  • Process each found record individually to prevent data from being lumped together.
  • Ensuring the loop references Current Item rather than the entire list.

4️⃣ Create Record Action (Master Email List):

  • Create a new record for each email found in the Contacts table.
  • Assign the corresponding Contact Name and Email Type.

The Issue I'm Facing:

  • The automation only creates one record instead of processing all found emails.
  • Some emails and contact names are getting merged into a single field instead of being split into separate records.
  • The Repeat for Each loop doesn’t seem to be functioning properly, even though it's set to process "List of Records" from Find Records.
  • Testing is limited because Airtable doesn’t support "Test Input List" with repeating groups.

What I Need Help With:

Ensuring each email is processed separately as an individual record.
Making sure "Repeat for Each" correctly references Current Item instead of pulling the full list.
Verifying that Find Records outputs the correct data structure for looping.

Has anyone successfully built a similar automation? Would love insight on how to correctly structure the loop and data references to get individual records in my Master Email List.

Thanks in advance for any help!

7 Replies 7
DisraeliGears01
7 - App Architect
7 - App Architect

Hmm, I was trying to think through doing this with conditionality, when the real solution is to just create a linked record relationship between your contact and email tables. Instead of your 4 email fields in contact, you just have 1 field linking to the email table, which can link multiple times to express various email types. Then you can use lookup/rollups in contact as necessary if you need to display only the email address instead of the linked object. 

Hey @p_finder25!

Do remember that repeating group block will iterate through each of the records found on the find record action block, and not each of the fields for each of such records. There is a big difference to it!

E.g. If Contact A has both Partner Email and Referral email, that is still one record on the list of the find record block: Contact A. 

Given that you cannot iterate through the different emails found in different fields, I would probably suggest either:
(i) including a script on your automation that will get the trick done, or
(ii) building as many automations as email fields you have, where each automation would focus on only one email field.

Given that you would just need to duplicate the automation, and change the condition and the mapping, I would probably go with option (ii) above.

Does this make sense?

Please let me know if this is not clear, or of if this does not answer your question :D. I'd be happy to help out.

Mike, Consultant @ Automatic Nation

p_finder25
4 - Data Explorer
4 - Data Explorer

Hey there thank you. That is what I was trying to do (one automation for each) cant seem to get it to work. 

Thank you - ill try it this way and let you know

Hey @p_finder25. I'm not fully getting the combination of trigger and find records that you are using on the latest screenshots shared. Would you mind further explaining?

With the right information this should be pretty easy to solve. Keep your hopes up!

Mike, Consultant @ Automatic Nation

Hey Mike - took some trial and error but came up with a script - and it works great now. thx for the advice (

// Airtable Script to Extract Emails from "Contacts" Table and Insert into "GU_EMAILZ" Table
let contactsTable = base.getTable("Contacts");
let emailsTable = base.getTable("GU_EMAILZ");

// Load all records from Contacts table
let query = await contactsTable.selectRecordsAsync();

// Define email fields to extract
let emailFields = {
"Email": "Primary",
"Partner Email": "Partner",
"Referral Email": "Referral",
"Connection Email": "Connection"
};

let recordsToCreate = [];

// Loop through each contact
for (let record of query.records) {
let contactName = record.getCellValue("Contact Name");
 
for (let field in emailFields) {
let email = record.getCellValue(field);
if (email) {
recordsToCreate.push({
fields: {
"Email Address": email,
"Email Type": { name: emailFields[field] }, // Correct Single Select format
"Contact": [{ id: record.id }] // Link to Contact
}
});
}
}
}

// Insert records into Emails table in batches of 50 (Airtable limit)
while (recordsToCreate.length > 0) {
await emailsTable.createRecordsAsync(recordsToCreate.slice(0, 50));
recordsToCreate = recordsToCreate.slice(50);
}

output.markdown(" Successfully extracted emails and linked them to contacts!");

Great! The script might be overbuilding, but if it works it works!!!

Glad to help out. If anything else comes up, feel free to schedule a call with me using this link.

Mike, Consultant @ Automatic Nation