Imagine that you always want to activate a checkbox in exactly one row in a Base. When this checkbox is activated, all other checkboxes that may be filled should be deactivated. You can easily perform this operation with a script, e.g. via a button.
Thank you for this input from the community
Many thanks to Jörg who posted this script in the SeaTable community forum.
The result
Each time you click on the button, the checkbox in this row will be activated and all others will be deactivated.
The complete script
// vars const viewName = 'Default View'; const targetCheckboxColumnName = 'Checkbox'; // code - don't change careless! const currentRow = base.context.currentRow; const table = base.getActiveTable(); const view = base.getViewByName(table, viewName); const rows = base.getRows(table, view); const selectedRows = [], updatedRows = []; // set check base.modifyRow(table, currentRow, {[targetCheckboxColumnName]: true}); // remove all other checks let pos = 0; rows.forEach((row) => { if (pos >= 0 && row[targetCheckboxColumnName]) { selectedRows.push(row); updatedRows.push({[targetCheckboxColumnName]: false}); } pos++; }); base.modifyRows(table, selectedRows, updatedRows);