I need help please

I wrote an SQL code to generate the firstName, surname, email, and dob fields from a Google Sheet when the mobileNumber is entered, and it worked by using {{query6.data[0].firstName}} as the default value for the fields, i.e. firstName, surname, etc.

SELECT firstName, surname, email, dob
FROM {{ DB.data }}
WHERE {{ mobileNumber.value }} = mobileNumber

Where I am struggling is that, it does not allow a new user to input their FirstName, Surname, etc, manually , i.e a case where the mobileNumber is not in the database. The essence of doing this is to help a repeat user generate their details without having to input them manually. Please help.

1 Like

Hey there!

The reason this is happening is because Event handler is set up to run on a change of the mobileNumber component. When you try typing out a new phone it triggers the query and probably sets you the values of the fields.

What you need to do is only trigger query6 when the phone is in desired format/length and only then trigger the query.

Once the query runs you need to set-up logic to fill out form if a valid result is found i.e. you will be setting First Name only if the query has results.

Does this help?

Thank you so much, @stefancvrkotic. It just worked.

Can you help me with a response for this: I need help to get this done - #3 by How
I am trying to multiply two fields to generate a value, automatically