# Trouble using tag value in tag event script

**URL:** <https://forum.inductiveautomation.com/t/trouble-using-tag-value-in-tag-event-script/53615>\
**Category:** Ignition\
**Created:** [December 1, 2021, 11:56am UTC](https://forum.inductiveautomation.com/t/trouble-using-tag-value-in-tag-event-script/53615 "2021-12-01T11:56:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tommy\_Evans](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tommy\_Evans](https://forum.inductiveautomation.com/u/Tommy_Evans)\
**Post date:** [December 1, 2021, 11:56am UTC](https://forum.inductiveautomation.com/t/trouble-using-tag-value-in-tag-event-script/53615/1 "2021-12-01T11:56:18Z")

</div>

I have the following code as a tag event script on a temperature tag

```auto
	value = int(currentValue.value) 
	tagPath = "[~]_Sample_Device_/Writeable/WriteableBoolean1.value"
	lowerLimit = system.tag.read("[~]lowerLimit.value")
	upperLimit = system.tag.read("[~]upperLimit.value")
	
	if value > upperLimit: 
		system.tag.writeAsync([tagPath], [0]) 
	elif value < lowerLimit: 
		system.tag.writeAsync([tagPath], [1])

```

I’m trying to get the code to use two number entry boxes to set an upper/lower limit at which to switch on/off a heater.  
The above code is not working but if I replace the limits in the code with numbers like this:

```auto
	value = int(currentValue.value) 
	tagPath = "[~]_Sample_Device_/Writeable/WriteableBoolean1.value"
	
	if value > 28: 
		system.tag.writeAsync([tagPath], [0]) 
	elif value < 23: 
		system.tag.writeAsync([tagPath], [1])

```

It works.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 1, 2021, 12:58pm UTC](https://forum.inductiveautomation.com/t/trouble-using-tag-value-in-tag-event-script/53615/2 "2021-12-01T12:58:51Z")

</div>

> [@Tommy\_Evans](#):
>
> ```auto
> tagPath = "[~]_Sample_Device_/Writeable/WriteableBoolean1.value"
> lowerLimit = system.tag.read("[~]lowerLimit.value")
> upperLimit = system.tag.read("[~]upperLimit.value")
> 
> ```

system.tag.read() return a QualityValue so you need to `.value`  
and .value its not needed in the tagpath

```auto
	tagPath = "[~]_Sample_Device_/Writeable/WriteableBoolean1"
	lowerLimit = system.tag.read("[~]lowerLimit").value
	upperLimit = system.tag.read("[~]upperLimit").value

```

---

<div class="post-metadata">

**Author:** ![Tommy\_Evans](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tommy\_Evans](https://forum.inductiveautomation.com/u/Tommy_Evans)\
**Post date:** [December 1, 2021, 1:36pm UTC](https://forum.inductiveautomation.com/t/trouble-using-tag-value-in-tag-event-script/53615/3 "2021-12-01T13:36:43Z")

</div>

That worked, thanks.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 1, 2021, 1:38pm UTC](https://forum.inductiveautomation.com/t/trouble-using-tag-value-in-tag-event-script/53615/4 "2021-12-01T13:38:11Z")

</div>

Happy to help^^
