# Write to tag.EngUnit

**URL:** <https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [August 12, 2019, 3:57pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369 "2019-08-12T15:57:52Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 12, 2019, 3:57pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/1 "2019-08-12T15:57:52Z")

</div>

Hi,

I have a script that works in 7.9 to write a new value into the EngUnit for a tag based on a boolean value.  
When running it in 8.0 it won’t change the value for me. I ran the script in the script console to check and got this error.  
Has something changed for writing to a tag property?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/68bdbd29c9cf9519764cd1118b1c3b5a533e88bf.png)

---

<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:** [August 12, 2019, 4:07pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/2 "2019-08-12T16:07:05Z")

</div>

What scripting function are you using? That looks more like an error indicating you’re not passing arguments into `system.tag.write[blocking, async]` correctly.

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 13, 2019, 8:39am UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/3 "2019-08-13T08:39:36Z")

</div>

The script i am running is from the UDT. I have pasted it below  
`system.tag"[.]../Engine Coolant Temperature" + ".EngUnit", "deg C")`

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 13, 2019, 12:40pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/4 "2019-08-13T12:40:16Z")

</div>

I think something went wrong with your paste.

It’s important to know which function you’re calling because some of them expect a list of tag paths and values, and the error you’re getting seems to indicate you’re calling one that expects a list but only providing a single value.

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 13, 2019, 1:04pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/5 "2019-08-13T13:04:40Z")

</div>

Apologies.  
`system.tag.writeAsync("[.]../Engine Coolant Temperature"+".EngUnit", "deg C")`

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 13, 2019, 1:08pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/6 "2019-08-13T13:08:43Z")

</div>

Ok, so [the docs](https://docs.inductiveautomation.com/display/DOC80/system.tag.writeAsync) show that it requires a list of tag paths and values.

You’d want something like this:

```auto
system.tag.writeAsync(["[.]../Engine Coolant Temperature"+".EngUnit"], ["deg C"])

```

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 13, 2019, 1:44pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/7 "2019-08-13T13:44:54Z")

</div>

I have changed the script to reflect what you suggested.  
it works for tag values but not for the .Engunit see below

```auto
system.tag.writeAsync(["[.]../Raw Data/Total Fuel Consumption - Conversion Factor"],[0.5])
system.tag.writeAsync(["[.]../Raw Data/Instantaneous Fuel Consumption - Conversion Factor"],[0.05])
system.tag.writeAsync(["[.]../Raw Data/Engine Oil Pressure - Conversion Factor"],[0.125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Conversion Factor"],[0.03125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Offset"],[-273])
system.tag.writeAsync(["[.]../Total Fuel Consumption" + ".EngUnit"],["l"])
system.tag.writeAsync(["[.]../Instantaneous Fuel Consumption" + ".EngUnit"], ["l/h"])
system.tag.writeAsync(["[.]../Engine Oil Pressure" + ".EngUnit"], ["kPA"])
system.tag.writeAsync(["[.]../Engine Coolant Temperature"+".EngUnit"], ["deg C"])

```

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [August 13, 2019, 2:56pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/8 "2019-08-13T14:56:54Z")

</div>

Try using `engUnit` for the property name, like so:

```auto
system.tag.writeAsync(["MemoryTag1.engUnit"], ["deg F"])

```

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 13, 2019, 3:04pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/9 "2019-08-13T15:04:14Z")

</div>

> [@mgross](#):
>
> .engUnit

Tried but still no luck.

```auto
if currentValue.value == 1:
	             
system.tag.writeAsync(["[.]../Raw Data/Total Fuel Consumption - Conversion Factor"],[0.5])
system.tag.writeAsync(["[.]../Raw Data/Instantaneous Fuel Consumption - Conversion Factor"],[0.05])
system.tag.writeAsync(["[.]../Raw Data/Engine Oil Pressure - Conversion Factor"],[0.125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Conversion Factor"],[0.03125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Offset"],[-273])
system.tag.writeAsync(["[.]../Total Fuel Consumption.engUnit"],["l"])
system.tag.writeAsync(["[.]../Instantaneous Fuel Consumption.engUnit"], ["l/h"])
system.tag.writeAsync(["[.]../Engine Oil Pressure.engUnit"], ["kPA"])
system.tag.writeAsync(["[.]../Engine Coolant Temperature.engUnit"], ["deg C"])
	else:
system.tag.writeAsync(["[.]../Raw Data/Total Fuel Consumption - Conversion Factor"],[0.132086])
system.tag.writeAsync(["[.]../Raw Data/Instantaneous Fuel Consumption - Conversion Factor"],[0.0132086])
system.tag.writeAsync(["[.]../Raw Data/Engine Oil Pressure - Conversion Factor"],[0.01812975])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Conversion Factor"],[0.05625])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Offset"],[-459.67])
system.tag.writeAsync(["[.]../Total Fuel Consumption.engUnit"],["gal"])
system.tag.writeAsync(["[.]../Instantaneous Fuel Consumption.engUnit"], ["gal/h"])
system.tag.writeAsync(["[.]../Engine Oil Pressure.engUnit"], ["psi"])
system.tag.writeAsync(["[.]../Engine Coolant Temperature.engUnit"], ["deg F"])

```

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [August 13, 2019, 3:08pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/10 "2019-08-13T15:08:22Z")

</div>

Exactly what happens when it doesn’t work? Is it the original error? Also, where is this script being run? Such as tag event script, gateway timer script, etc. I tried on a 8.0.4 nightly build with success, so knowing your exact Ignition version would help too.

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 13, 2019, 3:22pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/11 "2019-08-13T15:22:10Z")

</div>

I have it on a check box in a UDT.  
The conversion Factors are being written correctly just not the engUnit.  
Our version is 8.0.4 nightly.

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [August 13, 2019, 4:07pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/12 "2019-08-13T16:07:50Z")

</div>

Yeah, I can’t replicate any problems here with a UDT and updating the engUnit tag property. If you can export the project window and the UDT tags, you can post them either here or send them to Support. From there, we should be able to figure it out pretty quickly.

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 14, 2019, 8:35am UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/13 "2019-08-14T08:35:35Z")

</div>

The function works with memory tags. I tried even changing the engunits in the tag browser and it won’t work either. Is this a known problem.  
I have attached the UDT to this.  
[tags.json](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c6f59982f5d9d6aeb9ce1cbf118426aa6bc10b18.json) (89.3 KB)

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [August 14, 2019, 8:56am UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/14 "2019-08-14T08:56:59Z")

</div>

Found a temporary fix for the issue.  
The script will run ok when the override is ticked on the engunit in the instance.  
Is this a bug? It worked without doing this in 7.9

---

<div class="post-metadata">

**Author:** ![JasonWright](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JasonWright](https://forum.inductiveautomation.com/u/JasonWright)\
**Post date:** [August 16, 2019, 6:59pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/15 "2019-08-16T18:59:18Z")

</div>

I also have this issue when trying to write to tooltip, documentation and engunit in the metadata within a UDT instance.

My code on a tag change:

tagValue = system.tag.read("[.]TagName")  
toolTipText = tagValue.value +" - “+ currentValue.value  
system.tag.write(”[.]…/PV.Tooltip",toolTipText)

Seems like 7.9 automatically put an override on the property when the script ran and version 8.03 does not.

Manually selecting override also works for me.

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [August 23, 2019, 10:10pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/16 "2019-08-23T22:10:41Z")

</div>

~~This may have been fixed in the nightlies recently. As of today (8/23), I can write to a udt tag’s property and it will automatically create an override.~~ My example worked with one udt instance but not a different one. I’ll have to keep digging.

---

<div class="post-metadata">

**Author:** ![chris3145](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@chris3145](https://forum.inductiveautomation.com/u/chris3145)\
**Post date:** [August 23, 2019, 11:38pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-engunit/27369/17 "2019-08-23T23:38:47Z")

</div>

I have also found that in 8.0 a property must already have an override before I can write to it. Rather than checking boxes manually, I have been setting those overrides up programmatically via system.tag.configure().
