Apr 27, 2022 09:40 PM
HI,
I want to be able to select multiple records in a base and update a field in all selected records. I’m thinking this will probably need a script where I can enter a value and then push a button to update all selected records with that value.
Has anyone done this or have an idea to get me started please?
Thanks
Solved! Go to Solution.
Apr 28, 2022 12:55 AM
Ah, yes, that does complicate matters.
I’ve created a solution here, and you can view the script by duplicating the base.
This seems like overkill, but yeah I totall get what you mean when you say it’s for a client.
===
Do you think they’d be able to handle the following?
Apr 27, 2022 10:07 PM
Hi Jason, chances are you already know about good old shift and click to select multiple records and then paste (gif below), as well as Airtable’s Batch Update App, so I take it there’s something specific you’re trying to do that it can’t achieve?
If you could give me a specific example of what you’re trying to do I would be happy to try to help
Apr 27, 2022 10:28 PM
Hi Adam,
Thanks for for responding. It’ a little more complicated than that.
I have records, in a view, that need assigning to a project via a linked record field. When a record is added to a project i.e. the linked filed has a value, then the record disappears from the view due to the filter on the view.
Ideally I want to link one record to a view and then drag this value (or copy and paste) to other records that need assigning to the project. The problem is the record disappears when it is added to a project, so not there to drag the value to the other records.
I know there are work arounds but its for a client and I want to make it easy as possible so envisioned an option to select a bunch of records and then select a project and update them all.
Hope this makes sense
Apr 28, 2022 12:55 AM
Ah, yes, that does complicate matters.
I’ve created a solution here, and you can view the script by duplicating the base.
This seems like overkill, but yeah I totall get what you mean when you say it’s for a client.
===
Do you think they’d be able to handle the following?
Apr 28, 2022 01:51 AM
Hey Adam, thanks you so much. I really appreciate it and this is exactly what I was looking for. Awesome!!
Mar 08, 2024 02:10 AM
I had the same issue, especially when the field I wanted to update was used to filter the data as well!
My solution is not the best, but works for me. I created a separate checkbox column to select the rows I want to update. I also created a new view with only one filter → "checkbox is ✔". This way I can select the rows I want, move to the "Checkbox View" make any changes without the filtering getting in the way, and then return to my other view where I can also easily uncheck the previously selected rows.
I hope this helps
Aug 08, 2024 08:45 AM
Hi there thanks for this it's what I'm looking for but when I go to duplicate the base it says I don't have permissions to create automations?
Aug 13, 2024 02:59 AM
Hmm, it sounds like you may not have duplicated the base to your own workspace, here's a guide: https://support.airtable.com/docs/creating-a-new-empty-base#duplicating-airtable-bases
I'm also using a script extension and not an automation, and I've attached the code below. Script extensions used to be available on the Free plan but are now restricted to paid plans, thus the confusion, sorry about that!
let projectTable = base.getTable("Projects")
let projectTableQuery = await projectTable.selectRecordsAsync({})
let projectRecord = await input.recordAsync('Pick the project', projectTableQuery);
let table = base.getTable("Records")
let checkboxField = table.getField("Checkbox")
let fieldToUpdate = table.getField("Linked")
let query = await table.selectRecordsAsync({
fields:[checkboxField]
})
let recordIdsToUpdate = new Array;
for (let record of query.records){
if (record.getCellValue(checkboxField) === true){
recordIdsToUpdate.push(record.id)
}
}
let updates = new Array;
for (let id of recordIdsToUpdate){
updates.push({
id: id,
fields:{
[fieldToUpdate.id]: [{ id: projectRecord.id }],
[checkboxField.id]: false
}
})
}
while (updates.length > 0) {
await table.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}