# PropertyChange Script Error

**URL:** <https://forum.inductiveautomation.com/t/propertychange-script-error/24568>\
**Category:** Ignition\
**Created:** [May 1, 2019, 8:46pm UTC](https://forum.inductiveautomation.com/t/propertychange-script-error/24568 "2019-05-01T20:46:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [May 1, 2019, 8:46pm UTC](https://forum.inductiveautomation.com/t/propertychange-script-error/24568/1 "2019-05-01T20:46:22Z")

</div>

I have a Dropdown object on one of my windows, this object is populated by a Named Query.

This Dropdown is how a PDF is selected for the PDF Viewer.

While in test mode everything works just fine, when I actually run with a Client everything works just fine except when I leave(close) this window and move to another.

I get a scripting error - it tells me that a null value can’t be used to open the pdf.

So I’m assuming the the property change event fires for the dropdown when the window closes and this is why I get the NULL error (Nothing has been selected) But how do I handle this error so my program will work correctly.

Here is my script for the Dropdown object

```auto
# Check to see if the property that changed was the Selected Value property.
if event.propertyName == "selectedValue":
	
 	# Run the query to grab the file name and bytes using the new selected ID value.
		event.source.data = system.db.runNamedQuery("Sample2", {"fileid":event.source.selectedValue})
	

    # Grab the file bytes and name from the same row.

bytes = event.source.data.getValueAt(0, "data")

name = event.source.data.getValueAt(0, "filename") 
	
    # Load the bytes into the PDF Viewer component.
event.source.parent.parent.getComponent('Container').getComponent('PDF Viewer').loadPDFBytes(bytes, name)

```

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [May 1, 2019, 9:38pm UTC](https://forum.inductiveautomation.com/t/propertychange-script-error/24568/2 "2019-05-01T21:38:03Z")

</div>

> [@dcamp1](#):
>
> event.source.selectedValue

Try adding a check for the value like this:

```auto
if propertyName == "selectedValue":
     fileid = event.newValue
     if fileid > -1:
          event.source.data = system.db.runNamedQuery("Sample2", {"fileid":fileid})
	

  

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 1, 2019, 9:40pm UTC](https://forum.inductiveautomation.com/t/propertychange-script-error/24568/3 "2019-05-01T21:40:30Z")

</div>

Check your indentation. It looks like your later lines of code run for any property, not just for `selectedValue`.
