Populate search box from previous step

Screenshot from 2022-04-14 16-21-27

I am using a search box to select from a list of companies.
If the company is not listed, the user can click ADD NEW to create a new company.
This triggers a popup and the user can add the details and click SAVE.
The creates the new data thing, resets the inputs and hides the popup.

What I want is for the newly created company to now automatically populate the search box, rather than having to search for it after it has been created.

Can’t figure out how to do this…

Hi there, @steve26… one thought that comes to mind is to have a custom state that you set with the newly-created company when the save button is clicked. Then, you could have a conditional on the search box that sets the box’s default value to the custom state when the custom state is not empty. Want to give that a shot and see if it works for you?


Thanks for this @mikeloc … That all seems to make sense. But when I get to the part of needing to assign the value of the custom state to the default value of the input, i get stuck. Please see the two attempts and screenshots below…

My steps:
I attached a custom state to the SearchBox A element called “theCustomState”
I created a conditional for SearchBox A that says When theCustomState Is Not Empty
Default value …
And that’s where the dropdown list doesn’t seem to allow me to set the default value for the search box to the value of theCustomState…

So i looked at using the “Do a search for” option to set the default value to:
Distributor - company name contains [SearchBox A’s theCustomState]
See below. But that doesn’t seem to work either.

Any time you are referring to a custom state, you have to first select the page/element with which the state is associated, and then you will be able to select the custom state.

I think that’s what I am doing. The custom stat is attached to the search box, and that’s what I am selecting.

In the first screenshot, can’t you select This Searchbox's theCustomState (or Searchbox A's theCustomState) as the default value?

Hey @mikeloc I appreciate you’re ongoing look at this. Yes, have the option to select This Searchbox's theCustomState However, it asks for the selection of a further argument. If I don’t, it turns red. I have tried selecting further arguments, but they also turn red. Here is a screenshot of what comes up:

What is the type for the custom state? Is it linked to the company data type?

Well that was definitely part of the problem! I had the custom state type set to Text. But it still doesn’t populate the default value of the search box with the company. Now I think the problem is that when the popup closes after creating a new distributor, there is nothing to tell SearchBox A to NOW take the value of the Custom State that was just created. Instead it still has no value because theCustomState did not have a value when the page first loaded. Is there a way to tell the SearchBox to fetch the custom state value after the popup closes?

Here is the whole setup as I currently have it:

Custom state is set to Distributor

Screenshot from 2022-04-15 14-28-22

SearchBox A choices style set to Dynamic
Type Distributor
Sort by company name

Screenshot from 2022-04-15 14-32-09

Default value is set to This SearchBox's theCustomState

The SAVE button on the popup to add a new company has a step to set theCustomState to value Results of step 1 (create a new distributor)

That all looks like it should work… one question, though… in the conditional on the search box, why is the This element is visible option there? It looks like you are saying the element shouldn’t be visible when the custom state is not empty.

That did it! The visibility thing was an accident. Removed that and it totally works!
Thanks so much for your patience and help!!!

1 Like

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