Adalo hints: how to prevent from creating duplicate records in the collection (UPDATED with 2nd video)

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:

Second video with modal warning:

17 Likes

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

1 Like

Thanks, glad I could help!

@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?

1 Like

Hi @bhanu,

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:

@Victor thanks!

A separate question: can we access users phone contact and let them import into the application during or after the onboarding?

Scenario: I have a gift app where user needs to select contacts from phonebook to send a virtual giftcard for example.

Sorry, for using the current thread to ask this question.

Hi @bhanu,

Answered in the “Help” category thread, see here:

Best regards, Victor.

Hi @bhanu,

I’ve created the video with modal, see above.

Best regards, Victor.

@Victor cool, thank you!

1 Like

Hi Victor, thanks for the two videos.

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” …

You can change name of record with relationship between students and course. For example student_email+course_id and then check the name to unique.

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.

Many thanks again.

Hi @michaelyung,

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 :slight_smile:

Best regards,
Victor.

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 !!

Cheers, Michael

1 Like

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.

Maybe you found some other workorounds?

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

best regards
faisal

Hi @faalsaady,

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.

Best,
Victor.

I have ony big problem with that solution. When input is blank, I didn’t write nothing yet. Red sentence is showing all time.

Hi @AdrianD,

Welcome to the community :partying_face:

You can add a visibility condition to the button that Only visible when the Other Components > input > is not equal to > empty.

Thank you

1 Like