Jul 13, 2023 03:27 AM - edited Jul 13, 2023 03:30 AM
Context Unable to create an automation in Airtable. The path is as follows: An update in the "Sleep" field of Table1 triggers a search for records in Table2 that share a common field (using the "Name" field as the link). The automation then uses a script to update the corresponding records in Table2 with the updated "Sleep" content from Table1 into the Table2 fields, that have the same name, "NewSleep."
Automation Path Image Below:
My script is producing an error "'recordtoUpdate' is declared but its value is never read.(6133)." I believe what this means is the script doesn't understand or have a value it interprets from Table1 "Sleep" and therefore cannot update the the field of "NewSleep" for the records that have the corresponding name.
let records = input.config().records
let table1 = base.getTable("Table1");
let table2 = base.getTable("Table2")
let newsleep = table1.getField('Sleep')
for (let record of records) {
let recordtoUpdate = await table2.selectRecordAsync(record)
await table2.updateRecordAsync(record, {
'NewSleep': newsleep,
})
}
Solved! Go to Solution.
Jul 13, 2023 04:22 AM - edited Jul 13, 2023 04:22 AM
Check the value with "console.log(newsleep);".
getField()" cannot get the value of a record.
It is necessary to use "getCellValue()" to read the value.
Jul 13, 2023 04:22 AM - edited Jul 13, 2023 04:22 AM
Check the value with "console.log(newsleep);".
getField()" cannot get the value of a record.
It is necessary to use "getCellValue()" to read the value.