Help

Re: Script to flag duplicate records

3879 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Lucas_Ravassall
6 - Interface Innovator
6 - Interface Innovator

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!

image

5 Replies 5

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
image

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))
Davis_Chipman
4 - Data Explorer
4 - Data Explorer

If you’re still looking for solutions for flagging duplicate records I recommend checking out what we made at zzBots. Here is a link to our community forum that includes written and video instructions of how to install our " Airtable Flag Duplicate Records" plugin (pre-built bot).

I hope you find this helpful:)

I tried your script
by changing the second line like this
const [CHECK,MARK,HASDUP,DUP,UNIQ]=['PHONE','duplicates','A duplicates','Duplicate','Unique']

I just want a script that iterates through the phone column customer table and checks for duplicate phones
THANK YOU

I receive this message

ERROR Error
: the field "fldHrLg5ZiN1ETeaY" cannot accept the value provided.
to main line 10