Duplicated e-mail and/or phonenumbers

API used: “wix-crm-backend”

I have a list of contacts from another source that I would like to add to my Wix contacts.

To do this, I’ve created a function that will run as a ‘Scheduled Job’ and thus ensure that the contacts are up to date and created.

In this other source of mine, only emails are considered primary keys, allowing several contacts to have the same phone number.

However, I think I’ve found a bug (or some kind of concurrency problem - I don’t know how the contact database works under the hood).

Basically, I get this list (for this case it’s not important how) and I have a variable in the Wix backend with all the contacts.

After that, I go through the list and query the contacts by e-mail or phone number. If they exist, the data is updated to the values that come from the list. If it doesn’t exist, the contact is created.

However, if there are two contacts in the list with the same phone number (or the same e-mail address), both are created, when only one should have. Not even an error is shown.

There are two behaviors I was expecting:

  • That when handling the second contact, during the query, the first contact would appear.
  • That when creating the second contact, there would be some kind of error, since both the e-mail and the telephone number are primary.

I believe this is a bug or unexpected behavior because, if there is no duplicate data in the list and the function runs, and then more data is added to the list (including a duplicate) and the function runs again, the behavior is already as expected: the first appears in the query and/or gives the error when creating the second contact.