Creator Help

Delete duplicate records

It is possible to find the duplicate entries in the database and delete them. Below is the example of removing duplicate email entries in your database. You can replace the Email field with the field name that you want to find for duplicate entries.

Create a new function. The function’s script can be of the below kind:

myList = list();
duplicateRecordIDList = list();
for each record in myForm [ID != 0]
{
if ( myList.contains (record.Email) )
{
duplicateRecordIDList.add(record.ID);
}
else
{
myList.add(record.Email);
}
}
delete from myForm [ID in duplicateRecordIDList ];

Code explanation:

Create two lists. One for the duplicates and the other for the original.

myList = list();
duplicateRecordIDList = list();

Fetch all the records in the form

for each record in myForm [ID != 0]
{

Check if there exists a duplicate value, if yes, add the record ID to the duplicateRecordIDList list.

if ( myList.contains (record.Email) )
{
duplicateRecordIDList.add(record.ID);
}

If there is not a duplicate entry add it to myList List

else
{
myList.add(record.Email);
}
}

If you want to delete the duplicate entries,

delete from myForm [ID in duplicateRecordIDList ];

Top