Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Sep 10, 2021 09:47 AM
I would like to know how to copy a column “Items” from one table to another table.
Both table have the same naming “Items”
Table Name:
DB_Checklist
Daily_Closing_Checklist
View Name:
DB_Checklist > Closing
Field Name:
DB_Checklist > Items
Daily_Closing_Checklist > Items
I want to copy one of the row of data from DB_Checklist/Closing/Items to Daily_Closing_Checklist/AllEntry.
Can anyone show me how to code this?
let checklist = base.getTable("DB_Checklist");
let checklistView = checklist.getView("Closing");
let dailyClosingChecklist = base.getTable("Daily_Closing_Checklist");
I only know this much, want to learn more on how to make my table more automate.
Sep 10, 2021 11:24 AM
What are the types of these two fields? Also, define “copy” - do you want to create new records or append the said row to existing records?
//this loads the data
const source = await base.getTable("DB_Checklist").getView("Closing").selectRecordsAsync({fields:["Items"]});
//this preps an array as if we're creating new records in the other table
const toCreate = source.map( rec => rec={name:rec.name,fields:{"Items":rec.getCellValue("Items")}}
);
while(toCreate.length)
await base.getTable("Daily_Closing_Checklist")
.createRecordsAsync(toCreate.splice(0,50))
Typing this from memory, probably messed up a closing parantheses somewhere, but that’s the gist of the syntax. It all comes down to what exactly do you want to do.
Sep 10, 2021 01:58 PM
i might be totally missing the mark here. but it looks like you have the items linked to the closing checklist so you should be ably to use a lookup field? also i think airtable is meant to work a little bit different than this. again. i may be TOTALLY elementarizing your request. someone feel free to tell me im dumb but i think thats the answer youre looking for.
Sep 10, 2021 02:22 PM
I agree, it seems like they want to treat the two tables as spreadsheets.