Sometimes one needs to be sure that the value of the property in collection is unique for each record. As an example - you need to be sure that name of the company / restaurant / event / etc. is unique and record with this name can’t be added for the 2nd time.
UPDATE: added a second video how to make a modal window with warnings. Thanks for your comments inspiring that!
UPDATE #2: please note, the check is case sensitive; so “UGC ODEON” and “ugc odeon” will be treated as different entries.
Here is the short tutorial how to prevent from creating “duplicate” records:
Perfect. I’ve been struggling with this when trying to register customers and each time they transact. a new customer record is created for the same phone number. Thanks
@Victor thanks for sharing this, is there a way we can throw an error message to the user as a feedback that “The record already exists” on top of this solution? Maybe a Modal screen?
Thanks!
Of course that’s possible. You need to make button “always visible” though.
Also it’s possible to display a warning string at the screen. Here are the screenshots of the setup:
One question - seems the method works for collections like in your examples - company, restaurant, events etc. However, what about collections with relationships ?
For example, let’s say I have a collection for Students, one collection for Courses, and one for Enrolled Courses (with fields like name, Students relationship, Courses relationships). How I can stop duplicate records that one student enrolled to same courses multiple times ?
BTW, not sure why every collection has to has the field “Name” …
Thanks a ton !! I can set the Name with Student_email, but not the course ID. All I can get is a COUNT from the collection Courses.
In the form, there is a field Course ID, but I set filter to show pull down menu of Course ID … and therefore not an input field … not sure it causes the problem.
I’m assuming you’re creating a “Junction table”, to be able to have many-to-many relationships (students ↔ courses)?
One option is to use @oper2k approach.
There is a possibility to use the same approach as in the original video. I’ve created a small POC, see here:
As for your question about “Name” - (a) you can rename this property and (b) you can move the properties up and down in the collection setup (on the left pane). First property can’t be deleted, but other can be
Thanks Victor for the reply and the time to prepare for the POC video. Yes, what I want to do is to check uniqueness in the junction / associative table (which is popular in DB design). From your video, I believe you solved the problem by the way of presenting the course and the way of “enrolling” the course.
Shall give it a try and also see if it works for other presentation / form approaches. Many thanks again !!
This solution isn’t working wery well. Because if there will be some slow respond time betwen app and database, which hapens with Adalo quite often, duplicate records will be aded anywey. And if button will be pushed quickly several times in a row there will be even empty entries aded.
Thanks Victor for your explanation, I want to ask can I do this way to prevent the duplication in booking appointment for clinic. to make sure each patient should booked one appointment. other question, when he or she choose a slot , the slot will not be activate for other patients
The easiest way is to create a T/F property for Slot, call it “Booked”, and set it to True after booking.
And then you’re not allowing to book the slots with “Booked” = True.