How to find and remove duplicate records in my Form

How to find and remove duplicate records in my Form

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.
  1. // create two lists. one for the duplicates and the other for the original.
    myList = list();
    duplicateRecordIDList = list();
  2. // fetch all the records in the form
    for each record in myForm [ID != 0]
    {
  3. // 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);
    }
  4. // if there is not a duplicate entry add it to myList List
    else 
    {
    myList.add(record.Email);
    }
    }
  5. // If you want to delete the duplicate entries,
    delete from myForm [ID in duplicateRecordIDList ];
 
Refer the below links for help.
  1. http://help.creator.zoho.com/Functions.html
  2. http://help.creator.zoho.com/for-each-record-in-form.html
  3. http://help.creator.zoho.com/Built-in-Functions.html#List_Functions
  4. http://help.creator.zoho.com/Delete-Records.html
If you want to avoid duplicate entries in future, you can make the particular field value as unique . You can also referhttp://lounge.creator.zoho.com/tips-and-tricks/zoho-creator-show-unique-values-in-picklist-referencing-data-from-another-form , if you are playing with a list field.