Oct 25, 2021 08:23 PM
Hello, I’m trying to delete a massive duplicate records in my table about 10,000 to 20,000 records exist in my table. As i don’t know where to insert the proper condition if the records is duplicate by knowing they are older dates or not up-to-date/current date And I can’t delete them in one go due to script execute time.
// Read our table
var table = base.getTable("Weekly Metrics");
var query = await table.selectRecordsAsync ();
// Check whether any record in that table
// match the input
let duplicate = query.records.filter((record)=>{
return query.records.find((potentialDuplicate) => {
return record.getCellValue("Pages") === potentialDuplicate.getCellValue("Pages") && record.id !== potentialDuplicate.id;
//&& record.id !== potentialDuplicate.Id
})
});
// console.log(duplicate);
let updates = duplicate.map(update => {
return {
"id":update.id,
fields:{
"Duplicate?":true
}
}
});
while(updates.length > 0){
await table.updateRecordsAsync(updates.slice(0,50));
updates.slice(50);
}
Oct 26, 2021 09:18 PM
That’s not really how .map is designed to be used. It is for mapping one array onto a different array. You shouldn’t be deleting records in the array as part of the mapping process.
Feb 07, 2022 01:10 AM
Hello miss @kuovonne, is it possible to use the updateRecordAsync from base1 but the data will be put to base2. like base2.updateRecordAsync
Feb 07, 2022 06:59 AM
No. Scripting is designed to only affect the base in which the script resides. There are workarounds that involve accessing the REST API, webhooks, or third party tools to affect change in a different base. All of these workarounds add a layer of complexity.