# \[IGN-8411\] Value Changed Script Error - Error Expanding paramater referencejava.lang.NullPointerException

**URL:** <https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703>\
**Category:** Ignition\
**Created:** [April 11, 2024, 5:49pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703 "2024-04-11T17:49:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSI\_EXP\_Auto](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@MSI\_EXP\_Auto](https://forum.inductiveautomation.com/u/MSI_EXP_Auto)\
**Post date:** [April 11, 2024, 5:49pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/1 "2024-04-11T17:49:14Z")

</div>

This error only appears when I am using a UDT, what exactly is causing the error? What can be done to fix or produce results I'm looking for within a UDT? I have tried commenting out the lines in which I utilize curly brackets but that does not fix the error. Here is the code -

```auto
	current_value = system.tag.readBlocking(["[.]Current Value"])[0].value
	#body = "Current Value = {current_val}".format(current_val = current_value)
	body = ''
	if currentValue.value == 'Upper Alert':
		body = body + '\nIn Upper Alert State\n'
		
	elif currentValue.value == 'Upper Alarm':
		body = body + '\nIn Upper Alarm State\n'
		
	elif currentValue.value == 'Lower Alert':
		body = body + '\nIn Lower Alert State\n'
		
	elif currentValue.value == 'Lower Alarm':
		body = body + '\nIn Lower Alarm State\n'
	else :
		body = body + ' Compliant'
		
	if currentValue.value == 'Compliant' or previousValue.value == 'Compliant':
		system.tag.writeBlocking(["[.]Time Stamp"], system.date.now())
	Email_Notification.send_email(
		    	from_addr="automation@",
		    	to_addr=[recipients],
		    	subject = "My Devices Alert",
		    	body=body,
		    	cc_addr=[cc_recipients],
		    	body_type = 'html'
		    )

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 11, 2024, 5:54pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/2 "2024-04-11T17:54:35Z")

</div>

Where is this script? Please post the _entire_ error message in a preformatted text block.

Why are you reading a value into `current_value` but then never using it? Is this the entire script? It seems like things are missing.

Where is Email\_Notification defined?

---

<div class="post-metadata">

**Author:** ![MSI\_EXP\_Auto](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@MSI\_EXP\_Auto](https://forum.inductiveautomation.com/u/MSI_EXP_Auto)\
**Post date:** [April 11, 2024, 6:02pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/3 "2024-04-11T18:02:39Z")

</div>

The script is on a tag value change and the error appears in the diagnostics section, nothing appears in logs but the script just never runs even when tag changes. -

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/7/07c55096ddc99aeeece9389ca45f2db3fa2ba1ca.png)

The value I read in should be used in that commented out line, I commented this out because the error mentions parameters and I know curly brackets can be used to call parameters

Email\_Notification is a script I wrote and use in many other places, it is inherited by this project and sits in my project library.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 11, 2024, 6:09pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/4 "2024-04-11T18:09:37Z")

</div>

> [@MSI\_EXP\_Auto](#):
>
> I know curly brackets can be used to call parameters

Not in Python, ~~curly brakets are syntax for a Dictionary or a Set. In this case it would have been a Set.~~ Not true when the braces are included in a string...aggravating to miss that.

Assuming the script you provided is the full script, then you have several undefined identifiers.

- current\_value
- recipeints
- cc\_recipients

Tags are outside of normal Project Scope, and so any scripts that are called must either be built-ins, defined by objects, or defined in the Global Scripting project. You say that Email\_Notification is inherited by this project, Is the parent project the Global Scripting project?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2024, 6:10pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/5 "2024-04-11T18:10:11Z")

</div>

A NullPointerException is basically always a bug _in Ignition_, not something for you to fix, but what version are you using? It's possible it's already fixed.

---

<div class="post-metadata">

**Author:** ![MSI\_EXP\_Auto](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@MSI\_EXP\_Auto](https://forum.inductiveautomation.com/u/MSI_EXP_Auto)\
**Post date:** [April 11, 2024, 6:15pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/6 "2024-04-11T18:15:42Z")

</div>

The issue is in this line -

`#body = "Current Value = {current_val}".format(current_val = current_value)`

Once I remove this the error goes away, does not matter if it is commented out or not. Is there another way to format the strings in scripting without using curly brackets?

---

<div class="post-metadata">

**Author:** ![MSI\_EXP\_Auto](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@MSI\_EXP\_Auto](https://forum.inductiveautomation.com/u/MSI_EXP_Auto)\
**Post date:** [April 11, 2024, 6:17pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/7 "2024-04-11T18:17:29Z")

</div>

The error was due to the curly brackets. Did not matter that they were commented out, once fully removed the error disappeared.

---

<div class="post-metadata">

**Author:** ![MSI\_EXP\_Auto](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@MSI\_EXP\_Auto](https://forum.inductiveautomation.com/u/MSI_EXP_Auto)\
**Post date:** [April 11, 2024, 6:27pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/8 "2024-04-11T18:27:27Z")

</div>

Using `body = "Current Value = %f " % current_value` has resolved the issue.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 11, 2024, 6:43pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/9 "2024-04-11T18:43:32Z")

</div>

Interesting....

Now that you mentioned it, that did sound familiar. Low and behold:

> [@\[Bug Report\] Curly brackets (braces) on commented line in udt instance script causes script to fail silently](https://forum.inductiveautomation.com/t/bug-report-curly-brackets-braces-on-commented-line-in-udt-instance-script-causes-script-to-fail-silently/79124):
>
> Including open/close curly brackets (braces) with any text in between, on a commented line (e.g. #{z}), in a value changed event script, on a tag in a udt definition... causes the script to fail silently showing no errors in the script editor and no errors in the logs. Any of these lines causes silent failure of the script with no lines executed. #{L} # here is an innocuous comment that should not affect anything but {does} I tested for the same on atomic tags not in a udt definition/instanc…

Looks like it's either a known issue or very similar to one.

---

<div class="post-metadata">

**Author:** ![MSI\_EXP\_Auto](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@MSI\_EXP\_Auto](https://forum.inductiveautomation.com/u/MSI_EXP_Auto)\
**Post date:** [April 11, 2024, 6:56pm UTC](https://forum.inductiveautomation.com/t/ign-8411-value-changed-script-error-error-expanding-paramater-referencejava-lang-nullpointerexception/88703/10 "2024-04-11T18:56:18Z")

</div>

Looks to be the same, my search parameters were off because I initially didn't realize the curly brackets were the cause.

Hopefully if someone searches that error in the future this thread pops up. The multiple sources of finding errors can get annoying, I always look into the logs and forget diagnostics is also a place to look.
