How can I check for duplication of records using Script?

How can I check for duplication of records using Script?

The following sample code added to the Form actions -> on add -> on validate block and Form actions. -> on edit -> on validate block of the Script tab, will check if the same team member is added more than once to the Team Member form.  If true, the submit action will cancel.

if (count(team_member[name == input.name]) > 0)
{
alert "Name already exists";
cancel submit;
}

where,

team_member [name == input.name] - selects all the records from the team_member form whose name is equal to the name entered in this form.
input.name - it is the value for the field "name" given by the user while submitting the form
count - count operator returns the number of team members whose name is equal to the current name in the form (this.name)

    • Related Articles

    • Install Agent Using Startup Script

      Recommended for Active Directory enabled networks. Here are the steps involved to easily deploy Zoho Assist unattended agent across your network using Startup scripts of Group Policy Object. Login to Zoho Assist. Navigate to Settings, click ...
    • How can I update records in a form using Deluge Script?

      About the application  You can fetch and update records from a form using Deluge script.  Let us illustrate this with the help of an example. The application Library Manager has two forms: Books - To enter the details about each book with fields ...
    • How can I send mail to particular records using Deluge script?

      You can send mail to specific records in a form by using the sendmail Deluge syntax within a for each deluge statement. Refer the link Fetch a collection of records and iterate over them, for more information.
    • Check-Out and Check-In a Presentation

      If you want complete control over the content in your presentation, you can lock it using the Check Out option. Check Out allows you to edit slides without worrying about other users overwriting the content.   To check-out a presentation,  Click   ...
    • Search Records

      The search option helps locating specific information or specific records without having to go through the entire list of records, thus saving time in finding records. The different search options available in Zoho CRM are: Search by Alphabets Search ...