Hidden field value constraint

I’m trying to create a form where the user simply chooses their name from a dropdown list that is constrained by the name of their company (a particular company in the database). The idea is that only associates from that particular company will display in the dropdown box.

However, when I go to create a constraint on Search for Associates and try to set it to Company = value I’m looking for, it won’t allow me to choose a company name (endless loop of searches). It won’t allow me to type in a value. I even tried creating a hidden input and a hidden dropdown with the value I’m looking to use and then use the value of that hidden field as a constraint for the dropdown menu showing the names. While everything shows up in blue this way, no names show in the dropdown list when I have two entries in the database for that company.

How can I get this constraint to work? Why is it being so difficult?

Hi there, @bryan.beneker… if you have a company field on the Associate data type and that field is tied to the Company data type, then creating the constraint shouldn’t be difficult. The question is how does the form know what company you want?

When you create the constraint on the dropdown list of associate names, you shouldn’t have to do any searches or use any hidden inputs/dropdowns. It should be as easy as saying the company field on the Associate data type equals something like the Parent group's Company or another dropdown’s company (which is maybe what you were trying to do with the hidden dropdown) or whatever. Again, the question is how are you defining that company? If you can share some screenshots, I’m sure we can get it sorted out.

Best…
Mike

Hi @mikeloc

I will show you as much as I can. Below is literally all the page is.

Page

Below is the Associates data type setup. Company name is within the Company data type.

For the constraint portion, I thought maybe a video would be easier to take in than a bunch of screen shots so that you can see what my interactions with Bubble look like.
What I’m Seeing

Yup, it’s what I said… the form has no way to know which company you are trying to use as the constraint. How are you defining that company? Do you only have one company in your database? If so (and if just to see it work), you could set the constraint as Company = Search for Company's:first item.

Right now I have 7 dummy companies input for testing and development. What do you mean by ‘defined?’ Are you talking primary keys (fields)? If so, CompanyName is the primary for the Company data type.

I tried doing the Company = Search for Company’s:first item, and it doesn’t allow me any options like that.

Hmm, I’m not sure how to make this clear… maybe if we move away from the implementation in Bubble for a second. You have that sign in page, and you want the dropdown to show the names of associates who are part of a certain company, but you have 7 companies in your database. How does the app know which company you want to show the names for?

Oh, and you definitely can create the constraint I mentioned in my last response. Set Company = and then select the Do a search for option.

OK, I think I’m on the same page with you now. I guess inevitably your question of how I’m defining the company is what my actual question is for this post. I’m asking, “How do I define the constraint?” or “How do I let the app know which company I want to show names for?” We agree that that’s the problem.

I have another page for contractors that worked without a hitch at all. The page asks which company the person works for and then asks for their name. The names are based on the value chosen from the company list. I totally get how that works. And you’re right, you certainly can do the Company = Do a search for option. That’s how I did that one.

However, this page is a bit different because I’m looking at just visitors (who don’t show up very often). Not really a company, but it organizes things. I’ve taken a few moments to consider maybe I should just have the person type their name into an input and do it that way. The reason I wanted a list was because we have people show up for a few days at a time, and I didn’t want them to have to keep typing their name in each time they enter the building. Plus, it has the potential to disturb the integrity of the data (maybe they have a typo which messes up search results for compiling reports).

The reason I mentioned a hidden field was to feed the app the value of the company I’m trying to define so that it knows which names to put in the Associate dropdown list. I’m not sure how else to define that value?

Couldn’t you just have two dropdowns (like you are doing for contractors)… one for companies and one for associate names? So, it’s like if you’ve been here before, select your company first, and then select your name. You could have the dropdown for names disabled until a company is selected, and then the constraint on the names dropdown would be something like Company = company dropdown's value.

It’s really that simple, though… something has to tell the form which company you want to show the names for. For contractors, you are making the user select the company. If you don’t want to do that with associates, then you have to have another way to define the company.

Yup, that’s exactly how I have the contractors page set up (associates is disabled until a company is chosen). I guess I will go that route then. I will just have to adjust my sign in menu to remove the visitors option.

Or maybe I can define the visitors option when the user chooses that they are a visitor? Can we send that from the signin-menu page to the contractors page? Make the initial value of the company dropdown list be visitor based on the the user clicking the link?

I don’t know what you mean by making the company dropdown visitor-based, but you can know that a user clicked a visitor link, and you could send a URL parameter to the next page and then get that parameter from the URL and do something with it on that page.

So if someone clicks the visitor link on the signin-menu page, then the company dropdown on the contractors page will populate with visitor as the initial value for the company dropdown list. Is that what the URL parameter would do?

Yes, you can do that, assuming you have a visitor option in the company dropdown (which means you have to have a thing for it in the company data type).

That I do! I will give that a shot here momentarily.

1 Like

Cool. You could send a parameter like visitor=yes to the page, and then you can use a conditional on the company dropdown to set it to visitor when the visitor parameter (which you will get from the URL, of course) is yes.

OK, trying to follow your direction here, but I’m obviously not doing something right. Doing this took away all the company options.

Below is the parameters I’m sending from the signin-menu page to the signin-visitor page through the navigation workflow.

Below is the conditional I put on the company dropdown menu.

You don’t want to set the option caption, you want to set the default value to a search for the visitor company.

OK, I’ve wrestled with the default value and am not sure what I need to be putting in here. Do I actually do Search for Companys or do I do Get data from page URL? Nothing I’ve done has produced the correct result.

The URL parameter is just being used to trigger the conditional… the default value is going to be Search for Company's:first item with a constraint that is probably something like company name = Visitor (or however you can find the visitor company).

I’m going to show you what I have and let me know where I’ve messed up. Everything works fine except the default value does not show visitor. It just shows the entire list.

First step is on the signin-menu page where I’m sending the parameter to the signin-visitor page.

Second step is showing the settings on the signin-visitor page. I have the default value filled in and the constraint showing in the image below.

From best I can tell, I’m where I should be? Just the default value isn’t there.

Nope… it needs to be on the conditional tab. You had it set up somewhat correctly in the screenshot a couple of responses ago, except you were setting the option caption instead of the default value. So, clear the default value on the appearance tab, go to the conditional tab, set up the When condition you had in that other screenshot, select Default value from the dropdown under the condition, and set up the search there. Also, the constraint on the search should be CompanyName = Visitor (assuming that is the name of that company… literally type “Visitor” after the equals sign, which is a little tricky to do because you have to click in right place to be able to type it).