identify potential duplicates presubmit

identify potential duplicates presubmit

mmontoyammontoya Posts: 84Questions: 27Answers: 4

First and Last name combo are not unique. You can have two John Smiths, each could have a different phone, Date of Birth, etc.
But, I would like on presubmit to alert the user that another JohnSmith exists, giving them the chance to continue or cancel.

Is this possible?

This question has an accepted answers - jump to answer

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    I dont think so with just DataTables, unless you use Editor, DataTables is mostly just the table related stuff. (Unless theres a way that im not aware of).

    You can just use regular jQuery to check for unique values on $('#form').submit(), and if some are found, show an alert modal or something of the sort, and if the user clicks OK, submit the form.

    Or were you looking for someone to actually do all the jQuery for ya?

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    There are two ways to approach this:

    Client-side using preSubmit, whereby you could spin through the data in the DataTable as @jhyland87 suggests (I must admit I hadn't thought of this option before - interesting idea!).

    Or server-side, which I would generally suggest since you are working with the data that is current on the database (it is possible the client-side data will have gone stale if other people are also editing).

    Editor does have a unique validator, but that is per field. For two field you would either need to build a custom validator that just queries the database and checks if the value submitted is unique or not - very similar to the build in unique validator if you want to base your code on that, but with two fields of course.

    Allan

This discussion has been closed.