Maybe system.util.invokelater issue

I’m running following script in InternalFrameActivated event of the popup:

from java.lang import Thread
mixerBatchHistoryId = system.gui.getParentWindow(event).getComponentForPath('Root Container').mixer_batch_history_id

query = """
		SELECT 	osws.id as Reason,
				ocs.id as category
		FROM mixer_scrap_event mse
		JOIN oee_status_word_scrap osws
			ON mse.oee_status_word_scrap_id = osws.id
		JOIN oee_category_scrap ocs
			ON ocs.id = osws.oee_category_scrap_id
		WHERE mixer_batch_history_id = %d
		"""%(mixerBatchHistoryId)
scrapExists = system.db.runQuery(query, 'strvsqlp31')
print query
data = system.dataset.toDataSet(scrapExists)
if scrapExists:
	system.gui.getParentWindow(event).getComponentForPath('Root Container.scrap.category').selectedValue = data.getValueAt(0, 'category')
	system.gui.getParentWindow(event).getComponentForPath('Root Container.scrap.reason').selectedValue = data.getValueAt(0, 'Reason')
else:
	system.gui.getParentWindow(event).getComponentForPath('Root Container.scrap.category').selectedValue = -1
	system.gui.getParentWindow(event).getComponentForPath('Root Container.scrap.reason').selectedValue = -1

The Reason is depended on the category dropdown.

When I try to execute, it does selects appropriate category but not the reason !

Anyone here ?

Thanks

I don’t see any use of system.util.invokeLater in your posted script.

In any case my first guess would be that your path for the ‘reason’ property is slightly off and that the property is not being set.

Try adding these lines to your script for debugging.

# These lines will confirm the values returned from the db query
print data.getValueAt(0, 'category')
print data.getValueAt(0, 'Reason')

# Verify that we have valid references to components. If either of these are 'None' or wrong type then path is incorrect
print type(system.gui.getParentWindow(event).getComponentForPath('Root Container.scrap.category'))
print type(system.gui.getParentWindow(event).getComponentForPath('Root Container.scrap.reason'))

If you are getting values and both of the paths are referencing the correct components then I would examine the datatypes of the items returned in your query. Are they compatible with the ‘selectedValue’ proerty of your components?

Yes, the issue was, I was writing 0 to the selected value of reason whenever category was changed. Hence, when I was running this script, it would write to the selected value of reason but then the property change event of category would fire and write 0 to reason.