Hi, i'm landing with airtable and so far loving it, but I'm not sure if scripts works like other environments...
I have a table record with a lot of blank values at ID column because is an exportation from another ddbb and it exports fields with multiple values as a record for each value. Usually in other apps I make a script for this that get the variable when exists the ID value and replicate it at the next empty records ID until it finds a non-empty value and updates the variable, and so on.
I made the script and don't seems to have any fail but when executing is not doing anything (also no error text):
// Define the table and select all records
let table = base.getTable("Dashboard");
let query = await table.selectRecordsAsync();
let records = query.records;
// Initialize the lastref variable
let lastref = null;
for (let record of records) {
let currentDefaultCode = record.getCellValue("default_code");
let currentDefaultCodeNexus1 = record.getCellValue("default_code_nexus1");
if (!currentDefaultCodeNexus1) {
// If the "default_code_nexus1" field is empty, set it to the value of the lastref variable
if (lastref) {
await table.updateRecordAsync(record.id, {
"default_code_nexus1": lastref
});
}
} else {
// If the "default_code_nexus1" field is not empty, update lastref with the current value
lastref = currentDefaultCodeNexus1;
}
// Update lastref with the value of "default_code" if it is present
if (currentDefaultCode) {
lastref = currentDefaultCode;
}
}
Any ideas?