Script to flag duplicate records

Hi, I need a script to detect duplicates in a list with many records (15k+), I need the records column to work as a flag and that by means of a text or a checkbox notify me if I am adding any mail that is already above. The idea would be a real time process as fast and efficient as possible, that when someone finishes copying the new mail it will notify me if it is already up there

Thanks!

Hi @Lucas_Ravassallo
There is a free dedupe application in the marketplace that you can run to find and merge duplicates.

Hi,
You don’t need a script for it, if you want it to be done in real time.
You should add an automation that runs for each “Record created”.
Action will be “Find records” in your table, condition - email=email from new added record.
Then it should contain conditional action based on the length of ‘Find Records’ answer, like this

Action should update some field by your choice. To update checkbox field, you can put 1 or 0 into it. Also it can be true/false(or space, I don’t remember 100%)

For checking duplicates via script run, you can use this script, adjusting first 2 lines


const table=base.getTable('Your Table')
const [CHECK,MARK,HASDUP,DUP,UNIQ]=['field to check','field to mark','Has duplicates','Duplicate','Unique']
const query=await table.selectRecordsAsync({fields:[CHECK]})
const values=new Map(query.records.map(rec=>[rec.getCellValue(CHECK),rec.id]))
const others=query.recordIds.filter(id=>(![...values.values()].includes(id)))
const othervals=new Set(others.map(id=>query.getRecord(id).getCellValue(CHECK)))
const uniq=[...values.keys()].filter(val=>!othervals.has(val))
const upd=query.records.map(rec=>({'id':rec.id,'fields':{[MARK]:uniq.includes(rec.getCellValue(CHECK))?
UNIQ: others.includes(rec.id)? DUP:HASDUP}}))
while (upd.length) await table.updateRecordsAsync(upd.splice(0,50))