I want to write a small script that updates all status-fields in a given view.
Let’s say I have a view with tasks. Tasks have a status-field ( single-select: ‘new’, ‘busy’, ‘done’).
My script should update all status-fields for all tasks in a given view.
With input.config, I can select the base, view and field (status).
But I can’t find a way to select the new value of status for all those tasks.
Is there a way to accomplish this?
Because I want this script to be as generic as possible, I don’t want to hardcode any values. Idealiter, selecting done should return the id for that field. Something like.
let config = input.config({
items: <
input.config.table('selectedTable', {
label: 'Table to use',
description: 'Pick any table in this base!',
}),
input.config.view('selectedView', {
label: 'View inside the above table',
parentTable: 'selectedTable',
}),
input.config.field('selectedField', {
label: 'Field from which to select values',
parentTable: 'selectedTable',
}),
input.config.number('selectedOption', {
**HELP NEEDED FOR THIS PART!**
})
]
});
let option = selectedField.options.choiceslselectedOption].id
// select all records in this view
let allrecords = await selectedView.selectRecordsAsync({
fields: bselectedfield]
})
// update
for (let record of allrecords.records) {
console.log('updating:' + record.name)
await selectedtable.updateRecordAsync(record,{cselectedField.id]: {id: option}})
}
Is this even feasible?