Help with Script - Script to add all available records to linked record field

Here is my goal. I have three fields within my table as follows:

Button Field (for the purpose of running script, available in Beta)
Check Box Field (used for filtering view)
Linked Record Field

I am looking for script (or other method) to do the following:
Click button to run script
Script marks Check Box with Check
Script adds all available records from linked table in the Linked Record field.

For example, say there are 3 records in the linked table. When I click the button in the record in my table, the Linked Record field should populate with links to those three records.


I was able to get this code working:

let Table1 = base.getTable('Table 1');
let Record1 = await input.recordAsync("Select the Record",Table1)
let Table2 = base.getTable('Table 2');
let Query2 = await Table2.selectRecordsAsync();
let Records2 = Query2.records;
let d = [ ]
Records2.forEach(c => d.push({id:}));
await Table1.updateRecordAsync(,{'Linked Record Field': d});
let check = true
await Table1.updateRecordAsync(,{'Checkbox Field': check});
output.markdown('# Done')
1 Like

I am new to Airtables. Where do save and run this code please and which language is it? Thanks!

Glad you were able to get it figured out, @Michael_Andrew! You could also combine those two updateRecordAsync calls into one –

await Table1.updateRecordAsync(Record1, {
    'Linked Record Field': => ({ id: })),
    'Checkbox Field': true

Welcome to the forums @Peter_Vollawetscher!

This code is run in the scripting block, which can be found in the blocks gallery in your base. It’s currently free to use on all plans through September 2020! Scripts are written in JavaScript, and can interact with the data in your base – you can read more on the scripting docs site.

1 Like

Thanks. I know very little about programming, but can generally figure out from trial and error. I was able to work it out from other response so give rightful credit here:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.