"Do a search for" returning inconsistent values

Hi,

I have a table of email addresses and login count. If the user logs in for the first time I create a new record and set the count to 1. On subsequent logins, I increment the count.

Before inserting or updating, I “Do a search for” records based on email address. If the first item is empty, I insert a new record, else I update the existing record. I use the “only when” property for this.

What I’ve noticed is that if the user logged in on different days, the search returns empty, so I incorrectly create a new record for the user. However, if the user logged in multiple times in the same day, the search correctly returns not empty and I update the record instead. For e.g.:

  1. On Monday, user logged in for the first time. A new record gets created with count 1.
  2. The user logs in again multiple times on Monday. The existing record count gets updated.
  3. On Tuesday, user logs in, another record gets created. Now there is a duplicate record in the table for the same email.

Any thoughts / ideas on why this might be happening ?

Thanks!

you might want to drop a ticket with the support team. If they can reproduce the steps they can escalate and fix the bug. If there’s something missing they can walk you through the issue as well

Try to send some screenshots

Privacy rules

or this ^^^

1 Like

Attaching a screenshot of the two conditions. Thanks!


What is step 3 ?
Had you run in debug to see this result ?

Step 3 is an API call to a rest api that returns profile info. The profile info is parsed to extract the email address. The email address is always correctly fetched. The issue only happens with the “only when” condition.

I’ve reached out to the support team at Bubble as well. Waiting for them to finish taking a look.

Did you log the api response to be sure it always respond ?

It appears to be related to the privacy rules. I was not storing users correctly and the “Only when” condition checks against current user. The records were being stored against a temporary user. So the condition was false if a new temporary user was created on next lookup.

1 Like