Search value in data base

Hi! thanks for taking the time to read this question.

I want to validate a “4 digits code” that user puts in an input text, when clicks on “Validate”, I would like to search in a data type if this value exists, and if it’s true, it shows a meesage.

Is that possible?

Thanks in advance.

Regards

Pedro

That is definitely possible. Perform a search on the specific data type that contains the key as a field, and provide the code as a constraint for the field. If the count returned is greater than zero, there’s a match.

1 Like

Thanks Scott for replying.
Now I have another question:

  1. when do I have to perform this search? in an event when I click the button “Validate”?
  2. in the workflow, I dont have any “Search on the specific…” so, I dont know where and when I have to perform that search.

My idea is an input box to type the code (which should be recorded before in the database) and a button which will trigger a validation logic, returning a message “The code is valid” and putting a flag in the database for that code in “No”, so the code cannot be used again.

I really appreciate your collaboration!

thanks in advance

Pedro

When the validate button is clicked, you can add an ‘and’ condition where you could perform the search. Then the workflow is triggered if the conditions pass.

1 Like

Here’s a forum app example following Scott’s suggestion. :slight_smile: In this, the validation can be done when the button is clicked, or by using conditional statements on the text elements. I set up a test data type called “Code” and created two entries in the database (“1234” and “5678”). If you enter either of those codes without pressing the button, the text element will state that the code is taken immediately. If you type either of those codes and then press the validate button, an alert and text element will state that the code is taken. This app just shows alerts, but you could set the workflow to create a new thing when the code is not taken (or anything you choose).

Preview:

Editor:

WOW!!! Awesome explanation and example!! now, each record has two columns, the code and a yes/no column. When I click “Validate”, I want to change that record of the valid token putting that check in “yes”.

Many thanks for your support!

No problem at all! :slight_smile: If the code is valid, the workflow could be:

“When Button Usar Voucher is clicked and when Search for Validations: count is 0” --> Make Changes to Thing --> Thing to Change: Current Page Validation, Usado = “yes”

Then the other one is:
“When Button Usar Voucher is clicked and when Search for Validations: count is not 0” --> Make Changes to Thing --> Thing to Change: Current Page Validation, Usado = “no”

If you have a workflow with only “Button Usar Voucher is clicked” that workflow will run every time that button is clicked, so it’s best to use the additional “and when” statements to ensure that the correct workflow you need occurs when the button is clicked.

Thanks for your answer fayewatson!

Here’s my issue where I’m stacked. I tried that, but it seems something is missing on my actions:

Thanks for all your support!

Regards
Pedro

Ok, I think I did this well, but the database record is still no changing.

error could be:

  1. because first I’m clicking on “Check if valid” and it shows a message “Valid” if condition is true and then it enables a button “Validate it”. (anyway I put it in the first button and still doesn’t work)
  2. something else is wrong.

Can you share a link to the editor? I can change the workflows then explain step-by-step. :slight_smile:

here it goes:

Let me know if you can see it.

Regards
Pedro

Ok :slight_smile: I created a new page called testing because I didn’t want to remove parts from your original page. Is this how you need it to work? I don’t think you need extra steps to validate a code. When a User enters a 4-digit code, the ‘Save New Code’ button will only become clickable, and save the code on click if the code is not already taken. If there aren’t any codes that match the code entered in the input, then the button will become clickable and the User can save the code. If you would like a code that was taken to become available again, you can delete the code from the database using “delete thing” and that code will be available for a User to enter again.

1 Like

fayewatson! Many thanks for your help!! Every minute i’m more convinced about bubble and this community!

Well, I will explain my idea (the script) with this small form:

  • I will print a code for a customer. This codes belongs to a “medical appointment”
  • then the customer comes back some other day with that code
  • I check if the code is recorded. I receive a message that the code “Exists”. As the code was not used (used = “no”), I have now a new button saying “Validate it”.
  • when I click on “Validate it”, the used attribute for that code is changed to “yes”
  • if a customer comes back later with the same code, as this code will exist, and the used = “yes”, there will be a message saying “The code was already used”.

That should be the logic.
what I’m not being able to do: I cannot change the used attribute to “yes”. I dont know why :frowning:

Many thanks for your support!!

Best regards
Pedro

1 Like

So sorry about the delay - I thought I ran into a bug, but it was my error! Check again on the testing page. If you enter a value that has not been validated yet “5678” you can click ‘validate’ and it will change the value from no to yes. Then the repeating group will update its check box as well (it will go from unchecked to checked in the 5678 cell). If you uncheck that box, it will change the value from yes to no. If you check the box in the repeating group it will change the value from no to yes. I think this works as you need it to but definitely me know if something isn’t working as expected!

1 Like

Awesome!!! it works perfectly!!! That was exactly was I was talking about!!

Many many many thanks!! I hope someday I can help you as you helped me!

Thanks a lot!

Regards
Pedro

1 Like

Aw, that’s so nice!! My pleasure Pedro! :blush: Glad it’s working as you needed it to!