Dynamic initial value for dropdown


#1

Hey guys, new member here.
So i have a form page with some dynamic dropdowns. I’ve successfully bonded the dropdown to my data array data source.
The challenge for me is how to dynamically specify which option to initially set the dropdown to.
I only see an option for using index to set the initial value. This doesn’t work for my case because i’m not storing the index in my database but the values.
e.g on my page a user can select an option from the dropdown and save that page. The selected value will be stored in the database. If the user comes to that page to edit the form i want the dropdown to show the previously selected option.

I know i could save the dropdown’s option index value in my database but the problem is that these options can change, i.e. that application can add and remove options in the dropdown so this approach wont work.

For bubble users i’m just looking for a way to set the initial value of a dropdown dynamically the way bubble does it.

Thanks


#2

@sue I never got any response to this 10months after so I’m bumping it up. :grinning:


#3

Oops sorry don’t know why we missed this one…! :see_no_evil:

Yeah I’m fairly sure we don’t support this right now (let’s face it, if we could do it you’d have figured out a way :wink:) so let’s move this to feature requests.


#4

As you can see from the post this was my early days of dropsource.
I’ve since then got some few tricks up my sleeves.
I have a workaround for this it’s just that I have too many of the Dropdowns it makes the whole workflow too long to maintain.
For one Dropdown my trick works cleanly but when I have about 5 Dropdowns on a page, repeating such workarounds makes my workflow too long.

Maybe this brings up a new feature request.
It will be nice if we could create a workflow, which takes in some parameter, give it a name and call it multiple times.
Basically like creating a function and calling the function as in conventional programming language.
If you’re very familiar with bubble this will be like creating a “custom workflow”.

Btw I will later post the workaround for dynamically setting a Dropdown’s option using a value instead of an index.


#5

Cheers @seanhoots would be great to see your workaround. And yeah 100% agree on being able to reuse sets of actions, that’s one I often find myself wishing we could do… :grimacing:


#6

Just realized the workaround i had in mind for setting the value of a dropdown wont actually work because we can’t do basic maths operation like increment a value by 1.

Here was the idea:

counter = 0
selected_index = 0
selected_value ="some value"
while (item in Dropdown List){
  if (item == selected value){
    selected_index = counter
  }
 counter = counter+1
}
Dropdown.selectedIndex = selected_index

Unfortunately i can’t do the line counter = counter+1.
We can’t use maths.js to do this addition too because run request actions as i understand are asynchronous so inside a loop it wont work.

I guess we will have to wait till dropsource finally support some basic calculations, even a simple increment action will really help.
This is the 3rd time i’m suspending an app idea because of this dropdown issue :sob::sob::sob:
I guess its time to start rethinking alternatives to dropdowns for my apps.


#7

Gah that is frustrating and I definitely feel your pain, there are so many options that become possible just by having the ability to add 1… :disappointed:

On the plus side our software engineer @catencio is actually starting work on providing basic math operations in Dropsource right now. There have been a few challenges and questions we needed to figure out around the best approach for this in the current implementation of Dropsource (issues around number types on the different platforms, building the right user interaction for this within the events and actions workflow etc etc), hence the reason we haven’t done it already. No fixed timeline at this stage but it is happening, honest…! :pray: :sweat_smile: