Hey @Ann_Yeom!
To accomplish this, you'll want to add the checkbox field to your view.selectRecordsAsync query return.
From there, we can utilize a callback function to filter out any records that do not have the checkbox field checked.
const table = base.getTable("Resource Capacity Planning_Production");
const view = table.getView("Grid View");
const checkedRecords = await view.selectRecordsAsync({
fields: [
"Pillar & Domain",
"FY Q2 23 - Demand (FTE)",
"your_checkbox_field"
],
sorts: [
{field: "Pillar & Domain"},
{field: "Stack Rank"}
]
})
.then(queryResult => {
return queryResult.records.filter(record => {
record.getCellValue("your_checkbox_field") === true;
})
});
for (let record of checkedRecords) {
let recordPillarDomain = record.getCellValueAsString("Pillar & Domain");
let recordFte = record.getCellValue("FY Q2 23 - Demand (FTE)");
if (currentGrouping != recordPillarDomain) {
currentGrouping = recordPillarDomain;
runningTotal = 0;
}
runningTotal += recordFte;
await table.updateRecordAsync(record.id, {
"TEST Running Demand": runningTotal
})
};
I've added in the a placeholder field for you to replace with your checkbox field.
I didn't test this script, so you'll want to read over the field names and variables to make sure they align with the exact formatting of your field names.
Let us know if you run into any issues with the script. We'd be happy to hop in and help troubleshoot!