InternalFrameActivated vs InternalFrameOpened - whats the appropriate spot for this code?

I have a pop up that has a drop down menu and next to it a checkbox (initially UNCHECKED). The drop down contains a list of all contacts associated with the project, but checking the box changes the data query such that now it lists all contacts with the entire company instead of that specific project.

Now I have a instance of this where one of these popups has that, it uses a contact associated with the entire company instead of specifically the project, leading to the drop down to display <Select One> instead of his name. My initial ugly but working solution was to do this in the internalFrameActivated

    threadContact = system.db.runScalarQuery("SELECT contactId FROM listhdthreads WHERE idx = %i"%(threadId))
	def checkAllContacts(event = event, threadContact = threadContact):
		label = system.gui.getParentWindow(event).getComponentForPath('Root Container.DD_Contact').selectedLabel
		# I hate this if statement as much as you do I am sorry
		if label == '<Select One>' and threadContact != -1:
			system.gui.getParentWindow(event).getComponentForPath('Root Container.ChBx_ShowAllContacts').selected = True
	system.util.invokeLater(checkAllContacts, 1000)

Right now the Cache Policy is set to never. But I am thinking, would it be better to set the Cache Policy here to something else, and instead of running this every single time the pop up runs, put this script in the internalFrameOpened because the customer contact does not change very often.

I know this seems like a very minor problem but I can see this becoming a larger issue with some other plans for this project and would like to take the best/most efficient approach to this sort of issue.

1 Like