Create forms with query to read and create a email #13622
-
1- In the first screen I need to verify if the email is in the database already. I am using a query to create a new register and the query adds only the field with a binding relation email. But when I test with an email registered already, I can navigate to the next screen. How I can better this? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 1 reply
-
There are two ways to go about this. Both look the same to the end user, but under the hood there's a few differences. To explore this, I created an app with a form-field that requests an email from the user, and Premium Users
if ($("Action 1.Automation Result").value.length === 1) {
return "/exists"
} else {
return "/doesntexist"
} The Automation Result is an object containing an array named Value - if there is an email address already in the table, it will appear here, giving the object a length of one, and therefor navigating to (in my case) /exists. Free Users
{
"query": {
"equal": {
"Email": "{{ Binding.email }}"
}
}
} Where
if ($("Action 1.Query result").data.length === 1) {
return "/exists"
} else {
return "/doesntexist"
} As always, your variables, bindings, and keys, will be unique to your project, so this answer should be used as a template rather than a solution. There's always more that can be said, so the Budibase Discord Server is a useful place to be, and the Budibase Documentation is worth bookmarking to have open in a tab in the background for more guidance. I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Thank you. I am testing the aplication! |
Beta Was this translation helpful? Give feedback.
-
Hi @jaquelinedealmeida I'm sorry you're still having trouble. I've attached the export file of the app I used to explore this. I just used the sample data, and for ease I've included the table of emails on the home screen so you can copy/paste them from the table to the field for testing. 13622-export-1715330961240.tar.gz You can read about how to import apps in the documentation here. |
Beta Was this translation helpful? Give feedback.
-
Thank you!! It's working!
|
Beta Was this translation helpful? Give feedback.
-
Hi @mikesealey . I tested it again, but it's just going into the else. |
Beta Was this translation helpful? Give feedback.
-
For debugging purposes, temporarily remove or disable the "Navigate To" action and add in a "Show Notification" which contains the $("Action1.Query result"). In it's current setup we're looking for an empty array, but the if-statement will take you down the else-path if you get literally anything else, so it could simply be that we've made an incorrect assumption earlier that is causing unexpected behaviour. |
Beta Was this translation helpful? Give feedback.
-
I fixed with |
Beta Was this translation helpful? Give feedback.
-
Perfect, I'm glad you got sorted! |
Beta Was this translation helpful? Give feedback.
Hi @jaquelinedealmeida
There are two ways to go about this. Both look the same to the end user, but under the hood there's a few differences. To explore this, I created an app with a form-field that requests an email from the user, and
on click
of the button the app will check existing user emails. Using aNavigate To
action and some JavaScript to return the path of the page depending on the response of the checkPremium Users