Scripting to delete a value in a single select

I have a button/script that I want to be a toggle the value in a single select field. If the value is blank, I want to e button to mark it “Absent”; if the value is “Absent”, I want the button/script to make the cell blank.

In Airtable Scripting, I see how to delete choices, but I don’t think I want to delete the choice, just the value. (I am trying to avoid having a second option of “Present”, as I know my users will assume they have to mark all clear cells as “Present”.)

Here’s my script:

// Select the recordId that houses the button
let tableClassReg = base.getTable("Class Reg");
let record = await input.recordAsync('',tableClassReg).catch()

// read in a specific field
let entry = record.getCellValue("D1 Atnd");

// toggle that field
if ("Absent") {
    await tableClassReg.updateRecordAsync(record, {
        'D1 Atnd':{"name":""}  //<-- here's the problem
} else {
    await tableClassReg.updateRecordAsync(record, {
        'D1 Atnd':{"name":"Absent"}

I’ve tried “”, empty square brackets, null. But it doesn’t seem to allow me to force it to clear a value from a cell. Should I be using a different call?

Related: if I give a user a read-only view link, will the button fail to work at all?

Both of the following work for me:

await table.updateRecordAsync(record, {"Single Select": null})
await table.updateRecordAsync(record, {"Single Select": undefined})



Correct on all accounts. Thank you!
(I was really hoping I found a sneaky way around Airtable’s inability to grant limited access.)

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.