Help

Copy values from one table to another

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

When I add a new row in X table and click te button a script would copy all rows from /table into table. Is it possible with using script? I developed a script like below but it doesn’t work.

4 Replies 4
MikeBrown
4 - Data Explorer
4 - Data Explorer

How can I get the processed row’s value?
I mean if I click on the last link in the table “X” I want to get “New Y” text and use it in the script.

There’s a lot of info missing from your question, but I get the impression you’re using the new button field beta. Is that correct? Are you asking how to get the value for the record where you clicked the button?

Yes. you are right. Getting record of clicked on the button.

You first need to get the table where the record lives:

let table = base.getTable("TABLE NAME");

If the record is part of a specific view, you could use that instead of the table, but you still need to get the table first:

let table = base.getTable("TABLE NAME");
let view = table.getView("VIEW NAME");

Once you have the table/view, you can get the record (use only one of the following):

let record = await input.recordAsync("Pick a record", table);

OR

let record = await input.recordAsync("Pick a record", view);

The “Pick a record” text is irrelevant, as Airtable will know to grab the record where you clicked the button.

With that, you can get the name of the record (i.e. the contents of its primary field) using record.name, or any other field value using record.getCellValue("FIELD NAME")