# Vision Window with background color

**URL:** <https://forum.inductiveautomation.com/t/vision-window-with-background-color/78545>\
**Category:** Ignition\
**Tags:** ignition81, scripting, vision\
**Created:** [August 30, 2023, 5:17am UTC](https://forum.inductiveautomation.com/t/vision-window-with-background-color/78545 "2023-08-30T05:17:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surya\_Chandra\_Mohan](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Surya\_Chandra\_Mohan](https://forum.inductiveautomation.com/u/Surya_Chandra_Mohan)\
**Post date:** [August 30, 2023, 5:17am UTC](https://forum.inductiveautomation.com/t/vision-window-with-background-color/78545/1 "2023-08-30T05:17:19Z")

</div>

Hello,  
I am trying to highlight sensors (background color) which has incomplete components in it.  
When a user is selected from the dropdown, the highlight should happen  
The window has a dropdown of all the usersnames and a template repeater with 10 instances of the sensors and I have added the script in property change event but it is not working

 ![2023-08-30](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/4/a4e15489b04f4c74164b880b56edb2124e3ed11f.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 30, 2023, 5:34am UTC](https://forum.inductiveautomation.com/t/vision-window-with-background-color/78545/2 "2023-08-30T05:34:22Z")

</div>

Your whole script needs to be nested in this way:

```auto
if event.propertyName == 'selectedStringValue':
	#Indent all of your code one indention and nest it here

```

Otherwise, any and all properties that change will fire this script causing it to run multiple times when the selections change and causing it to run unexpectantly when other properties change.

If that doesn't fix your issue, paste your code into the post, then highlight the code, and click this button:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/c/ec3add95bbb270039c1b69cd1d82674915bcefc4.png)  
That will make your code copy and paste-able, which makes it easier for us evaluate your code for other problems.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 30, 2023, 6:29am UTC](https://forum.inductiveautomation.com/t/vision-window-with-background-color/78545/3 "2023-08-30T06:29:08Z")

</div>

Looking at your picture a little closer, my guess is that your script should be refactored to look more like this:

```auto
if event.propertyName == 'selectedStringValue':
	selected_user = event.newValue
	sensorRepeater = system.gui.getParentWindow(event).rootContainer.getComponent('Template Repeater')
	if selected_user == 'ALL INCOMPLETE COMPONENTS'
		#Primary Query Here
	else:
		#Alternate Query Here
	
	for sensor in sensorRepeater.loadedTemplates:
		#
		# Put All Evaluate hasIncompleteTasks bool logic Here
		#
		if hasIncompleteTasks:
			sensor.background = system.gui.color('red')
		else:
			sensor.background = system.gui.color('white')

```
