Help with Multidropdown showing only one of each value

Screen Shot 2020-02-11 at 8.18.09 PM

When users start to type their company, it should only show it once, not show it multiple times if it is the same company. How can I set this up to show it only once?

Here’s a description of what’s going on (because it is interesting), followed by the fix. I agree that the behavior of Multdropdown is confusing, but it turns out it’s exactly the same as if you spat out the values for “Choices source” into a text element. Here’s what’s going on:

When we “Do a Search for… (some Thing)” this will only only yield a list of unique Things, right? Because all Things coming fresh from the database are unique. So your “Choices source” does the following:

  1. It retrieves a list of “User Inputed Jobs” (which must be a Thing… aside: I find this a strange name for a Thing and what I think you mean to retrieve is the list of Jobs that were Created By a given User. You might want to rethink your database structure is all I’m saying.)

So this returns a list of job-like things. Let’s say for the sake of argument that there are 7 of them (like in your example shown above).

And then (#2. below) you:

  1. Ask for the text found in the “Company” field on each “User Inputed Jobs”.

What this returns to us is not a “Bubbleized” “list”. It is, in fact, a JavaScript style array. And that array can have duplicates.

More specifically: A mapping operation from the list of "User Inputed Jobs"s is executed, whereby we take each User Inputed Job and fetch the value of its Company field and put it into an array. And it’s this array that gets returned to us.

If you’re pseudocode savvy, it’s like:

what_we_are_returned = list_of_user_inputed_jobs.map(job => job's Company)

SO, this yields us an array of seven texts. Seven Jobs, seven texts.

NOW, some of these texts are, in fact, the same. In the example you post above, what you have is:

Job 1’s Company = “outreach”
Job 2’s Company = “syniverse”
Job 3’s Company = “drift”
Job 4’s Company = “gartner”
Job 5’s Company = “reliaquest”
Job 6’s Company = “gartner”
Job 7’s Company = “outreach”

And so what we get is an array like: [“outreach”, “syniverse”, “drift”, “gartner”, “reliaquest”, “gartner”, “outreach”]

And this feels unexpected because we think of Bubble “lists” as not having duplicates. But it turns out that this object we get returned to us has not yet been “Bubbleized”. It’s a like a JavaScript array (which can have duplicates), NOT like a Bubble list (which, internally, must be something like a JavaScript “set”… which cannot have duplicates).

So this “list” can have duplicates until we do some Bubble operation on it that forces the duplicate items to disappear.

Additionally, even if those text items were de-duped, we’d probably want them not in a random order, but in some sensible order (like alphabetical ascending).

SO, THE FIX IS THIS:

In this case, your “Choices source” should be:

Search for User Inputed Job's Company :unique items :sorted by (some criteria)

:point_up: The output of that expression will be an array of texts like this:

["drift", "gartner", "outreach", "reliaquest", "syniverse"]

And your option captions will now make sense.

IMPORTANT ASIDE: While the behavior I describe above will happen even if you do things “the right way” and you will need to de-dupe and sort your results, I encourage you to rethink how you’re organizing your data. Specifically:

A “Company” is not a text. A Company should be its own data type (its own Thing in Bubble nomenclature), even if it that data type only has one field (“Name” of type text).

What you should be doing here is as follows:

A “Job” should have a field of type “Company” on it and that field is NOT A TEXT… it is of type Company. A Company, at a minimum, has a Name field (type text which stores the company name).

In such a database schema, your dropdown would be set to Choices source:

Search for Jobs (constraint Created By = some_user [you probably mean "Current User])'s Company :unique items :sorted by (criteria Name)

:point_up: You still have to :unique items the list because 7 Jobs will yield 7 Companys and some of the Companys may be the same – it’s still an array and not a Bubbleized “list”. And they’ll still be in a random-ish order so you want to sort them, probably by their Name field.

The “Type of Choices” would then be Company (not text… and you’d be selecting a Company, not just getting some text that may or may not represent a unique Company).

Your dropdown’s “Option caption” would then be:

Current option's Name

(That is “show me the NAMES of the Companys I can select from but return to me a COMPANY / list of Companys, not a text”.)

1 Like

Screen Shot 2020-02-12 at 9.14.04 AM

I found another fix to this by using a SearchBox and including this in the workflow. It only shows one of the company.

I am not 100% understanding what you mean by the last part you said on making company its own data type, even if I found this fix would you still recommend it?