How to select a specific value of a dropdown after an event

Hi all!

I’ve got a drop-down where users can select values (it’s populated from a custom Data Type), or (using a separate input) can add values to the dropdown list (adds values to the custom Data Type). What I’d like to do is when a new value is added to the custom Data Type via the separate input, have the value just added be selected in the dropdown automatically.

The closest I’ve been able to come is to:

  1. Set the default of the dropdown to a custom state value (which is blank to start off with)
  2. When the new value is added to the dropdown, I set the custom state value to the new dropdown option and it populates in the dropdown just fine.

This works multiple times, as long as a value in the dropdown hasn’t been selected manually. Once a manual selection is made, the default value is no longer loaded automatically.

So I’m looking for a way to either directly set the value of the dropdown to some value, or to force a reload of the default variable from the custom state.

Here is my specific case, if it’s helpful at all:

  • I’m building a character editor for a game, which will allow various calculations to be performed based on various numerical attributes of the characters (calculating possible damage, etc.). Character is the Custom Data Type.
  • The user will be able to select one of their characters from the dropdown, which will bring up various fields to be edited (that will be used in other screens as input data for modeling purposes; not important here).
  • I have a different input where the user can add a new character to the database, and I’d like that new character to populate the dropdown automatically. Not a huge deal, but a nice experience, and understanding how to do it (or if I simply can’t) will be good learning for me.
  • When I first load the page and the default value in the custom State is null, I can keep adding new Characters and the dropdown updates correctly every time, as long as I do not manually select a value in the dropdown.
  • Once I select a value in the dropdown, the dropdown value never changes again on a new character add.

Hopefully the above is enough information, but I’m happy to provide more if needed.

Hi @steven.g.bass, and couldn’t you use the following expression in the default value field that I send you in a print.

Thank you for responding! But that doesn’t work, at least once an entry has been manually selected. At that point I guess the system is set to not pull in the default value is it would override the user’s current manual selection. (at least that’s my assumption). I’m able to determine the value just fine (I had tried first item/last item previously), but it’s not determining the value that’s the problem, it’s just getting it to pull in anything all that is the problem.

1 Like

Wrap the dropdown in a group and then reset this group everytime a new value is added to the list. This way the default value (set to be the custom state) will be applied again, but now using the new value.

This worked perfectly - thank you!!

1 Like