How do I make an option set option unselectable from a dropdown menu?

Good morning

I hope someone can assist me with the following challenge:

  1. On a job order page, there is a dropdown menu with many option sets options.
  2. These same option set options are fields for particular types of users (employees).
  3. I want that when a user with a particular option set option doesn’t exist in my databse, that that particular option is not selectable from the dropdown menu.
  4. By not selectable I mean either that the option doesn’t show in the dropdown, but preferable that it does show but is simply not selectable (maybe like in a faded lighter coloured text).

I hope I have described my challenge clearly and look forward to being guided in the right direction.

Hi @phrase9,

I wish I could help but I don’t quite understand. How would the option exist in the dropdown if it doesn’t exist in the database? Could show a screenshot with a use case example?

Thanks for the reply.

The option does exist in the database. But the various options of the option set are also fields of a user “thing”. If no user exists with a specific option as their field, I want that specific option to be unselectable in the dropdown menu.

Just apply a filter to the option set, and filter out the ones you don’t want accordingly - that won’t make them unselectable in the dropdown (I’m not sure how you can do that in a standard dropdown), they just wont appear in the dropdown at all…

If you wanted them to appear, but be ‘unselectable’, you’d probably need to create your own dropdown with a group focus and a repeating group.

1 Like

Thanks Adam. I hadn’t used filtering before so I have been fiddling with it but am unable to figure out how to refer to the users and their fields when filtering. Allow me to explain my use case more clearly with the following example:

  1. There is an option set called skills. The option set has the following options: programming, plumbing and singing.

  2. There are registered users who needed to choose one of the above 3 option sets in a profile field called skills when signing up. Adam chose programming as his skill. Jack chose plumbing as his skill. There are no registered users who have chosen singing as a skill.

  3. A visitor to the site is on the job order form where part of the form is a drop-down of said skills option set.

  4. Because no registered user exists who has chosen singing as their skill, I want “singing” not to be displayed in the drop-down.

How would I go about filtering to reach this result? I imagine I need to use “search for” and then “user” and then their “skill” field…but here is where I get lost

hey @phrase9 ,

thanks for explaining, it was hard to understand without an example. So if you have a dataset with skills, and in your users dataset you relate each user to a skill (or skills). Then a filter does a trick. Simply search for all skills where advanced: do a search for users whose list of skills contains this skill count > 0

Right I see…

There are probably a few ways to do this…

The first, and obvious way, is to do as you suggested: simply do a search for Users, and display each item’s Skill, with Unique Elements added to only display each Skill option once.

That’s the simple way - but as you’ll be searching your entire User database every time you’re displaying the dropdown at can be pretty slow once you have a large number of users.

We had a very similar requirement on one of our apps, and originally did just that. Whilst it was fine to begin with, we found it became too slow to be much use pretty quickly as the number of database items being searched increased.

Alternatively you can apply a filter to the option set based on how many Users have each skill - but again that requires a search of your entire User database, so may become too slow.

So, a much better way to handle this is to have a simple, and lightweight, method to define which options are displayed, and be able to change that programmatically via workflow actions in your app.

If we were able to modify Options and their attributes via workflows (the way we can with database objects) this would be simple - just have an attribute on the option set that determines whether or not an option is displayed (originally set to no), and anytime a User adds an option that isn’t displayed, jut change its display field to yes. Simple.

However that’s not possible with Option Sets currently in Bubble - but there’s a simple way to do almost the same thing, and it works very well for us and is super fast.

So here’s what I’d recommended: (we use this method to handle 'Category’s in our app - we have a large option set of categories, but we only want to display categories on pages that have products, users, or blog posts associated with them, so we use this method and it works great).

Create a new datatype that will be used to define which Options (Skills) will appear in your dropdown (in your case call it something like ‘Skills To Display’).

All you really need on this datatype is a single field, that is a list of Skills (the option set), although if you have different places in your app where you want to display different lists of skills for different things you can include more fields as needed.

Then just add a single database entry, with no skills set in the skills field (although you can pre-define which skills to show here if you already know which ones you want to display).

Then run a workflow anytime a User signs up with a new skill to add that skill to this item’s list of skills.

Then, for the datasource of your option set, just do a search for this ‘Skills To Display’ database entry (it’s super quick as there will only ever be a single entry), and use the list of Skills as the datasource.

That way you have full dynamic control over which options are displayed or not, can add new ones dynamically via workflow actions when users add new skills, and it’s very lightweight so loads very quickly.

Don’t forget you’ll need to have a database object in both your dev and live databases.

@adamhholmes thanks for that explanation. I am going to give your suggestion a try and see how it works. Will update you later.

@hanan1 thanks so much for taking the time out to make the app. I was excited as it looked like it solved the issue but the difference is in your app skills is a thing so it is searchable, but in my app it is an option set list, so it is not searchable. I did try “get an option” instead of “do a search” and I mimicked the rest according to your app but the result was the dropdown list showed no choices when there should have been one.

There is one obvious suggestion that, if you believe the lead UX designer at my day job (and to be honest, I’m not sure I do), is easier to implement and actually adds value. You could leave all of the options in the dropdown, and when an option is selected that doesn’t return any users, show an empty state with some messaging that might lead to a desired outcome.

So, using your example, if there are no users who chose singing as a skill and you remove that skill from the dropdown, a user who is searching doesn’t even know they can search for users who sing because that skill isn’t listed as an option. If you do list it and they select it and no users are returned, you could show a message such as, “There are no users with this skill yet, but check back often because new users are signing up every day!”

Anyway, as I said at the beginning of this response, this suggestion is obvious, and at least one highly-paid UX designer says it’s the way to go. What do you folks think?

Best…
Mike

1 Like

@mikeloc Your UX designer friend knows what he is talking about. I was actually thinking about this and I fully agree that from a UX point of view this is best.

The question I am currently dealing with of course is how exactly to achieve this.

I think that part shouldn’t be too hard. I assume you are showing the users in a repeating group. So, you could have a text element on the page that is only visible when a count of the repeating group’s list of users is 0. You could also hide the repeating group using the same condition.

on the order form page that has the skills dropdown, I am not showing any users. The users will be notified of orders behind the scenes if they have a skill that matches a skill chosen in the dropdown, so the question remains how to identify a skill in the dropdown that no user in the database possesses. I am going to try Adam’s suggestion this evening but if you have any thoughts to add please feel free

I’m sorry I don’t see why filtering does not wrk? Even as option set, you can still filter skills if you have that option set as a property in your users dataset.
https://drive.google.com/file/d/1Feq7TDZccRhYpWMgFgFLxa45IzQSRuLk/view?usp=sharing

Hi Hanan

Its bizarre, I replicated exactly what you did in the video but my dropdown becomes empty even though there are users with fields that match the option set. I even created a new user to double check, gave him a new field, but dropdown still gives no options.

Could it perhaps be that in your app, users and freelancers are different things whereas in my app its just users?

As Adam mentioned in his response, there are multiple ways to meet the requirement here (which is almost always the case with Bubble), and your way is certainly one of them, @hanan1. The real question, though, is which way is going to be most performant given that we now know that @phrase9 is essentially doing form validation as opposed to showing a constrained/filtered set of users in a list.

Given this more complete picture, I would almost certainly go with Adam’s suggestion of having a list somewhere that includes the used skills (i.e., skills that are associated with at least one user). Then, when a skill is selected in the dropdown, check to see if the skill is in the used list, and if it is not, show a message saying there are no users with that skill. Checking the selected skill against the list is certainly going to be faster than searching the entire user set to see if any user has the skill, so again, that is likely the way I would go here.

@mikeloc agreed. will update you guys if the solution worked.

@hanan1 to update you, I managed to replicate the option set video solution you posted. it turned out I did it right but that the options take a long time (around a minute) to display so that’s why I thought they were empty. Is it normal for it to take so long seeing as I only have 3 users in this application? (The option set list has around 100 options, so is this why it is so slow?)

Hi, i have a diferent situation, but maybe you can solve my prioblem. I want to do this filter on mu dwopdown, but, how if i want to show list off user that has no skill.
i mean this filter is show user with chosen skills, but how if i do a opposite. Can you help me please?

note: i don’t use skill for filter, but date. So, the admin can make event, and add a user in certain event, with date range. But, the rule is no allow every user to add in more than one event, at the same date range.
for example, Alex is added to ABC event, at 1 - 3 March, so, he cannot be added to other event, on this range. Thank you

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