Help

Move Record From One Table To Another Script - Help Needed

Topic Labels: Scripting extentions
1692 4
cancel
Showing results for 
Search instead for 
Did you mean: 
Zach_B
4 - Data Explorer
4 - Data Explorer

I’ve been trying to modify a script I’ve found on the airtable community that would allow me to click a button and trigger a script to move a record to another table. But it seems that in the process, it moves every record in the table. Is there a way to make it only move ONE record?

let table1 = base.getTable(“New Leads”);
let table2 = base.getTable(“Following-Up With”);
let result = await table1.selectRecordsAsync();
for (let record of result.records) {
if (record.getCellValue(“Move To Following-Up”)) {
await table2.createRecordsAsync([
{
fields: {
‘Name’: record.getCellValue(“Name”),
‘Email’:record.getCellValue(“Email”),
‘Phone’:record.getCellValue(‘Phone’),
},
}
]);
await table1.deleteRecordAsync(record.id);
}
}

This is the script I have currently, any help is appreciated

4 Replies 4

Hi,

you are on a right way
that will help you
input.recordAsync

you should change a few lines and remove loop from code

Welcome to the Airtable community!

It looks like it moves every record that has a value in the “Move To Following-Up” field. Was this your change to the script or did it already exist in the script?

I can look into it

I have no coding nor scripting experience lol, just found this script on the forum and tried modifying it

It already existed in the script before

I have no experience with scripts and coding so I just played around and reverse engineered a few things. But obviously couldn’t get those to work lol