Help

Create a script to check a checkbox

2307 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Livio_Ait-Ali
4 - Data Explorer
4 - Data Explorer

Hello,

I do not have a lot of programming knowledge so Im struggling with something that I think is quiet easy, but I could not find the answer online (at least not an easy one).

I would like to create a script that I could run on demand to check all the boxes if Label contains “Roadmap-visible”

Something like if Label contains “roadmap-visible” then checkbox = true

image

I know it is easy to do it with automation and I have already done it but I would like to do it with a script because it is more practical to run the command on demand.

Thanks a lot for your help :slightly_smiling_face:

1 Reply 1

Since the value for all the affected fields is being changed to the same thing, it would be most convenient to change the values of a whole View at a time.

Create a view that filters records to ones where “Roadmap-visible” is one of the selections.

Then make your script:

let table = base.getTable("Table Name");
let view = table.getView("View Name");
let query = await view.selectRecordsAsync({fields: []})

let updates = query.records.map(r => {
  return {id: r.id, fields: {"Checkbox": true}}
})

while (updates.length > 0) {
  await table.updateRecordsAsync(updates.slice(0, 50))
  updates = updates.slice(50)
}