I have written the following script which attempts to check if a field has the value "Definition" and if so make selection on specific single selection fields on a random basis. The reason for this is that the values will be used in a series of image mockups.
I am completely new to both airtable and scripting so have absolutely no idea why this script doesn't do anything, but also doesn't throw any errors. I also don't understand (despite being on the pro trial) why I can't seem to add scripting as an extension - it just says 0/10 added. However, when I go to the automation tab in the table, I can see the script I added (along with another one that works).
base.getTable("Pre Mock Prod (YP-PP)");
let query = await table.selectRecordsAsync();
let records = query.records;
for (let i = 0; i < records.length; i++) {
let currentRecord = records[i];
let posterType = currentRecord.getCellValue("Poster Type");
if (posterType.name === "Definition") {
let options = ["_p_design", "_p_layout", "_p_color_style", "_headline_border", "_p_orientation"];
let randomIndex = Math.floor(Math.random() * options.length);
let randomOption = options[randomIndex];
let selectedOption = currentRecord.getCellValue(randomOption);
let recordId = currentRecord.id;
await table.updateRecordAsync(recordId, { [randomOption]: selectedOption });
}
}
I am completely and utterly stuck...help!!