I'm attempting to read the current status of a single select field, what I'd like my script to do is read the status of the button and simply return that status as a string. For example, if I manually set the button to "Doing" and run the script, my script should return "Doing" from the console.
My airable is setup with a single table called "Item Status" that lists all the records in the table. Each record has a "Current Status" field, a single select field with "To Do", "Open", and "In Progress"
// read the current status of a record
let table = base.getTable("Item Status");
let queryResult = await table.selectRecordsAsync({fields: ["Current Status"]});
console.log(queryResult);
let record = queryResult.records[0];
console.log(record.getCellValue("Current Status"));
The problem is when I run this script it returns more data then I want.
CONSOLE.LOG
{id: "selkMEZY58GC8AUfc", name: "Open", color: "blueLight2"}
id: "selkMEZY58GC8AUfc"
name: "Open"
color: "blueLight2"
I don't need to know the id, or color, I'd prefer for now to only return the string "Open" if the button is set to open. I understand that each type of cell has a typeDef but I don't understand how to read from this typedef
TYPEDEF
{
choices: Array<{
id: string,
name: string,
color?: string,
}>,
}
This is part of a simple project where I'm trying to record the status of each record and keep a log of when it was updated in order to track how long each record is in each status.