How to make button click input value change persistent

Good day fellow Bubblers.

The Scenario.
I have a field and a search button. On hitting search the result is returned in a group.
In this case I’m searching for customers. If the customer is not found, a “New Customer” button should be clickable. I have the logic for this. The issue comes when the person enters a new search value and does not hit the search button. My new customer button now says, you already have some return in the group so I’m going to allow you to proceed. I need a way to make sure the group result is based on whats typed in.
The simplest way I can imagine is to have a hidden input which gets updated every time the search button is clicked. That way I can just say, if the hidden value = the search field then we’re all good to do the rest of our validation. I have put a condition on the hidden input to say when the search button is clicked, set the content to the search input. The issue is the value does not persist. ie. It will have the value as long as the button is clicked. Once I let go of the mouse the value defaults. My question to you then is how do I make it persistent?
example

Have 2 Workflows for the search button:

  1. When clicked, if the value in the SEARCH INPUT equals a Customer, then do not show New Customer Button
  2. When clicked, if the value in the SEARCH INPUT does not equal a Customer, then show New Customer Button

OR

Do not have the Button Visible at all and only have this workflow

  1. When clicked, if the value in the SEARCH INPUT does not equal a Customer, then show New Customer Button

I understand the logic. In normal coding it’s not complicated to write. I’m having issues understanding how I write this in Bubble. I’m lost for such a simple thing. I want to pull my hair out!!!

Give me 10 minutes and let me make a quick demo to see if it helps

Sorry it took awhile.

I have the example below. This new customer button will appear only when the Search box doesn’t match any customers. This is a basic example but you should be able to copy it so it will apply to your website.

Search Terms to test: Companies

  • Elon Musk
  • Steve Jobs
  • Jeff Bezos

Terms not in database:

  • Walt Disney

Your solution is under the Adding new customer button
Website: https://fun-sandbox.bubbleapps.io

Development Site: https://bubble.io/page?type=page&name=index&id=fun-sandbox&tab=tabs-1

Thank you Sir. Just putting the kids to bed then I’ll have a look.

No problem

1 Like

FINALLY!!! So what I did.
New customer button is hidden on load.
I made a custom state to ensure that which happens before the search and after is the same. Search button updates the state.
Set the state check to be a condition on the new customer button for making it visible.
I created 2 workflows for the hide and unhide based on the count of the search return.
I created a workflow to hide the new customer button if the value in A changes.

EduKit thanks for sharing the Development Site. Putting a shape(?) in front of an entry box is interesting if I looked correctly. My 2 week knowledge of Bubble shows, I didn’t know I could have multiple workflows for the same button/item which ties into the simplicity of show / hide that you demonstrated. In your case you create the customer on a additional screen. I create the record right off the bat and in MSSQL so while I’m preventing duplicates at DB level no one wants to see an DB error when pressing a button.

This topic was automatically closed after 70 days. New replies are no longer allowed.