Creator Help

Delete Duplicate Records

You can create a Function to identify and delete the duplicate records in your Form.

To create a new Function,

  1. Click on Workflow -> Functions tab. 
  2. In the pop-up window, choose the Write script / Copy sample function option.
  3. Copy and paste the below code in the editor.
  4. Replace the myForm and Email field with your Form Link Name and the Field Deluge Names
  5. Click on Done and Save the script.
  6. You can execute the function and remove the existing duplicates from the Form.

Below is the sample script for removing duplicate email records in your Form. You have to replace the myForm variable with your Form Link Name and the Email field with the Field Deluge Name that you want to check for duplicate records.

Sample code to delete duplicate records 

void deleteduplicaterec()
{
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 a function with two lists. One list to store the duplicate records and the other for the original records.

void deleteduplicaterec()
{
myList = list();
duplicateRecordIDList = list();

The for each record task fetches 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 wish to delete the duplicate entries,

delete from myForm [ID in duplicateRecordIDList ];
}

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocreator.com