Skip to main content
Solved

Toggle checkbox with Script

  • September 21, 2022
  • 2 replies
  • 61 views

Forum|alt.badge.img+2

I was wondering if there’s any script that allow me to check/ uncheck the box? I can only do one but I want to make a toggle checkbox.

This is the script for check only

let table = base.getTable("Product List");
let record = await input.recordAsync("Interest", table);
let recordId = record.id;
await table.updateRecordAsync(recordId, {
    "Interest" : true,
})

Best answer by Tom_Keysers

Try getting the current value of that record’s checkbox field and just inverse it using !.

Something like this (untested code):

await table.updateRecordAsync(recordId, {
    "Interest" : ! record.getCellValue("Interest"),
})

2 replies

Forum|alt.badge.img+14
  • Inspiring
  • 28 replies
  • Answer
  • September 21, 2022

Try getting the current value of that record’s checkbox field and just inverse it using !.

Something like this (untested code):

await table.updateRecordAsync(recordId, {
    "Interest" : ! record.getCellValue("Interest"),
})

Forum|alt.badge.img+2
  • Author
  • New Participant
  • 3 replies
  • September 21, 2022

Try getting the current value of that record’s checkbox field and just inverse it using !.

Something like this (untested code):

await table.updateRecordAsync(recordId, {
    "Interest" : ! record.getCellValue("Interest"),
})

Thank u so much. It works perfectly.