Dropdown not updating on selection

I’ve got a dropdown that is dynamically set on page load (which works). Once this is populated, making a choice is supposed to:

  • Assign values to 3 page variables
  • Change the displayed value of three Titles, one for each of the page variables
    (This is accomplished by binding those Titles to their respective variables).

These actions actually occur properly - it’s just happening when the dropdown list is tapped a second time (to change the choice that was made) …when it’s tapped a second time, the Titles update like they should have when the values changed for the dropdown.

So my problem is, I can’t figure out how to trigger all this properly - the only event I have to work with for the dropdown list is the “Component Tapped” event. How do I get it to go through the actions when a value is first chosen from the list?

Hi there!

I think the onChange event for the dropdown should be helpful in your scenario.

It’s available directly for the dropdown primitive you can find in the very bottom of the component library.

It’s also pretty easy to setup for the dropdown field component:

  1. on the logic canvas use the “receive event” node and choose “fired from trigger event” as the event source.

  2. In isolation mode for the dropdown field, select the dropdown component (this is the same as the primitive) and use the “trigger event node” and target the dropdown field custom event you just created.

Hope this helps!

If I followed your suggestion correctly, @Akseli_Virtanen, nothing changed. My flow:

  • “Page Mounted” updates a page variable which is bound to the dropdown choices (works)
  • 3 Titles are each bound to a page variable which should be updated when the user makes a choice in the dropdown.
  • The user makes a choice in the dropdown. “Component onChange” set in the dropdown (via isolation mode) triggers a flow on the page to update the 3 page variables above. (works)
    THIS IS WHERE IT FAILS: The flow is executed, but things do not work correctly. In the flow:
  • an app variable (property of an object) is set as the selected value of the dropdown.
  • according to the value of the app variable above, certain values are set for the 3 page variables which are bound to the Titles mentioned before.
    WHAT HAPPENS IS:
    The process works, but it’s one step behind. The next time I make a different choice on the dropdown, everything does what it is supposed to do …for the PREVIOUS value of the dropdown. It’s like the app variable that all changes are based on (and what is supposed to be updating before all other processes) is not updating until the end of everything - so that the next iteration uses the value from the previous choice, instead of the current choice.

To be clear - the page variables that should be changing are linked to the “set app variable” function which doesn’t seem to be doing its job until the end of all processing.!

1 Like

Any more thoughts here, @Akseli_Virtanen?

Hi

Can you post a screenshot of the formula for the set app variable? I did try a few things to create a similar scenario, but couldn’t quite reproduce the issue yet.

…I’m not using a formula, I’m using the interface’s binding. Here is the screenshot of the app variable - you’ll see I’ve got a page variable set up right below it - both do the exact same thing when I convert everything to see the page variable vs the app variable.
When I first test the app and make a choice from the dropdown, both of the Alerts give me a blank (I assume because it is still null). The second choice I make, the Alerts give me my previous choice, and the Titles update to that previous choice.

Ah now I see what the problem is. To get the latest value of the dropdown, you should either:

A. bind the dropdown value to a variable, which you then use in the set app variable assigned value.
B. bind to the output value of the onChange event, which will you give you the current dropdown value as the event object (you can use a formula to parse out just the eventValue aka. the dropdown value in this case).

The logic here is that binding to the dropdown value captures the current dropdown value, while in the onChange event we’re still in the process of changing the value. I’ll make a note about this for us internally to discuss if the behaviour makes sense as it is.

Personally I recommend option “A” as then you’re separating your concerns as:

  1. dropdown changes a variable
  2. variable is used elsewhere to determine further values

That did it (Option A) - Thank you, @Akseli_Virtanen

3 Likes