Help

Re: Select multiple records & update

534 0
cancel
Showing results for 
Search instead for 
Did you mean: 
christargett
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there, someone has already asked this question on this thread: https://community.airtable.com/t5/other-questions/select-multiple-records-and-update/m-p/115586/high...

But I don't think it is active any more. I have duplicated the base to get the automation but I don't have the permissions to do so. Would anybody be able to help me on how to create this automation please?

 

 

4 Replies 4

That base was created by Adam @TheTimeSavingCo, who is an Airtable consultant. I suggest you contact him directly.

Ok Thank you I have reached out- if he shares the solution I'll pop it in here 

Thanks for the tag @kuovonne !

@christargett I've replied in the original thread and have pasted it below for your convenience as well!

====

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);
}

 

 

 

Thank you so much for coming back with this. I am going to have a go with it (Airtable Newbie) so may be back with more questions

Appreciate your help