Mar 28, 2020 10:37 AM
I am trying to duplicate a row from one table to another (using scripts). The table I am copying from has a column with “rating” type field in it.
How do I go about duplicating in the createRecordAsync script?
I tried something like
let table1 = base.getTable("Table1"); let table2 = base.getTable("Table2"); let table1Rec = await table1.selectRecordsAsync(); await table2.createRecordAsync({ "Memo":[{icon: "star",max:table1Rec.getCellValue("Memo"),color:"yellow"}] }
I got an error. Summarizing it:
“(property) “Memo”?: 0 | 1 | 2 | 3 | 4 | 5
Type ‘{ icon: string; max: number; color: string; }’ is not assignable to type ‘0 | 1 | 2 | 3 | 4 | 5’.
Type ‘{ icon: string; max: number; color: string; }’ is not assignable to type ‘5’.(2322)”
May 04, 2020 11:00 AM
Got it, thanks folks!
Oct 26, 2020 09:30 AM
Is there a way to use a for loop to iterate through all of the fields instead of having to hardcode each one in?
Thank you!!
Paul Warren
Dec 05, 2020 12:11 PM
I tried using your suggestion for 2 tables with identical rows and I’m getting this error on a multi-select column called ‘Genres’:
L: Can't create records: invalid cell value for field 'Genres'.
Could not find a choice with that ID or name
The code and tables are really simple:
let table = base.getTable("Source");
let query = await table.selectRecordsAsync();
let targetTable = base.getTable("Target");
for (let record of query.records) {
await targetTable.createRecordAsync({
"Book": record.getCellValue("Book"),
"Genres": record.getCellValue("Genres"),
"Cover": record.getCellValue("Cover"),
});
}
Any ideas?
Dec 06, 2020 11:08 AM
Dec 07, 2020 12:23 AM
Thank you, that worked perfectly!