# Trouble auto-selecting on a dropdown who's options are based on parent dropdown?

**URL:** <https://forum.inductiveautomation.com/t/trouble-auto-selecting-on-a-dropdown-whos-options-are-based-on-parent-dropdown/32284>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 14, 2020, 5:05pm UTC](https://forum.inductiveautomation.com/t/trouble-auto-selecting-on-a-dropdown-whos-options-are-based-on-parent-dropdown/32284 "2020-02-14T17:05:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 14, 2020, 5:05pm UTC](https://forum.inductiveautomation.com/t/trouble-auto-selecting-on-a-dropdown-whos-options-are-based-on-parent-dropdown/32284/1 "2020-02-14T17:05:06Z")

</div>

I have a dropdown `Customers` and a dropdown `Locations`. Locations dropdown options are based on what is selected in the customers dropdown. I wanted to make it so that if the lcoations dropdown only had two options (A ‘Select …’ which we have as a row hardcoded into our named query, and something else), we’d automatically select the location.

I have a value change script on my Customer value. When it changes, if auto-select is on, see if the location only has two rows, grab the value of the none ‘Select…’ row, and pick it.

```auto
if autoSelectOn:
	data = self.getSibling("DD_Locations").props.options
	dataRows = data.getRowCount()
	system.perspective.print("Location has %i rows"%(dataRows))
	if dataRows == 2 :
		for row in range(dataRows):
			value = data.getValueAt(row, 0)
			system.perspective.print("Value: " + str(value))
			if value != -2:
				system.perspective.print("We got the value to change location to")
				self.getSibling("DD_Locations").props.value = value
				break

```

Here’s what I notice happening. If I have a customer with 30 locations, and then switch to a customer with only 2 locations (including ‘Select…’), the `system.perspective.print("Location has %i rows"%(dataRows))` says that there are 30 rows. So it’s grabbing the options of my locations before they seem to have a chance to update. So this isn’t working at all. I tried doing a `self.getSibling("DD_Locations").refreshBinding('props.options')` before I assign `data = self.getSibling("DD_Locations").props.options` but it did not do anything. I know there’s no system.util.invokeLater with perspective. Is there a way around this?

It seems like I have a race condition where my customer value change script runs and finishes before location data is updated appropriately for my customer script to make sense.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 14, 2020, 5:27pm UTC](https://forum.inductiveautomation.com/t/trouble-auto-selecting-on-a-dropdown-whos-options-are-based-on-parent-dropdown/32284/2 "2020-02-14T17:27:53Z")

</div>

The solution was to put a change script on the child dropdown options, that way there is no race condition. We know when the new data comes in programatically.
