# Using UDT tags in script editor

**URL:** <https://forum.inductiveautomation.com/t/using-udt-tags-in-script-editor/12340>\
**Category:** Ignition\
**Created:** [November 10, 2016, 2:25pm UTC](https://forum.inductiveautomation.com/t/using-udt-tags-in-script-editor/12340 "2016-11-10T14:25:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Csantaw](https://avatars.discourse-cdn.com/v4/letter/c/9de0a6/32.png) [@Csantaw](https://forum.inductiveautomation.com/u/Csantaw)\
**Post date:** [November 10, 2016, 2:25pm UTC](https://forum.inductiveautomation.com/t/using-udt-tags-in-script-editor/12340/1 "2016-11-10T14:25:48Z")

</div>

i’m trying to evaluate if there is something in a text box or not on a property change. if there is something greater than 0 I want to write a ‘true’ or 1 to a Boolean tag in my UDT. I cannot seem to get this to write if I select it as bound template tag. I get an error saying tag does not exist. I can write the value fine if I put the tag in the script editor directly. below is an example of what I am trying to achieve.

this is with a custom property. i’ve tried with or without the “” around tag. my custom property is bound to my template UDT tag on the page. I’ve also tried not defining ‘tag’ and putting ‘event.source.tag’ directly into the system.tag.write() statement.

`tag = event.source.Tag
if event.source.text != "":
	system.tag.write( "tag" ,1)
if event.source.text == "0":
	system.tag.write( "tag" ,0)
if event.source.text == "":
	system.tag.write( "tag" ,0)`

I’ve also tried writing directly to my UDT tag as shown below. I get the same “tag not found error”

`if event.source.text != "":
	system.tag.write( "event.source.parent.Receving_Bay.PLCTruckRoute" ,1)
if event.source.text == "0":
	system.tag.write( "event.source.parent.Receving_Bay.PLCTruckRoute" ,0)
if event.source.text == "":
	system.tag.write( "event.source.parent.Receving_Bay.PLCTruckRoute" ,0)`

below is an example of what I have working currently. the problem is I need to create 2 screens one to write to bay1 and one to write to bay2. (not really a problem just a nuisance)

`if event.source.text != "":
	system.tag.write("Tag/SAP/Receiving_Bay1/PLCTruckRoute",1)
if event.source.text == "0":
	system.tag.write("Tag/SAP/Receiving_Bay1/PLCTruckRoute",0)
if event.source.text == "":
	system.tag.write("Tag/SAP/Receiving_Bay1/PLCTruckRoute",0)`

any ideas? ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

---

<div class="post-metadata">

**Author:** ![accyroy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/accyroy/32/3386_2.png) [@accyroy](https://forum.inductiveautomation.com/u/accyroy)\
**Post date:** [November 10, 2016, 2:53pm UTC](https://forum.inductiveautomation.com/t/using-udt-tags-in-script-editor/12340/2 "2016-11-10T14:53:46Z")

</div>

I think you need the absolute path to the tags.

```auto
[]Tag/SAP/Receiving_Bay1/PLCTruckRoute
```

See the Tag Paths section of the manual for more info:  
[docs.inductiveautomation.com/di … +Organized](https://docs.inductiveautomation.com/display/DOC79/Keeping+Tags+Organized)

---

<div class="post-metadata">

**Author:** ![Csantaw](https://avatars.discourse-cdn.com/v4/letter/c/9de0a6/32.png) [@Csantaw](https://forum.inductiveautomation.com/u/Csantaw)\
**Post date:** [November 10, 2016, 5:08pm UTC](https://forum.inductiveautomation.com/t/using-udt-tags-in-script-editor/12340/3 "2016-11-10T17:08:18Z")

</div>

Hi accyroy,

this code works fine.

`if event.source.text != "":
   system.tag.write("Tag/SAP/Receiving_Bay1/PLCTruckRoute",1)
if event.source.text == "0":
   system.tag.write("Tag/SAP/Receiving_Bay1/PLCTruckRoute",0)
if event.source.text == "":
   system.tag.write("Tag/SAP/Receiving_Bay1/PLCTruckRoute",0)`

I’ve been messing around with it and reviewing the manual with the page you sited I should be able to do this statement.

`number = "event.source.parent.Receving_Bay.System_Number"
tagPath = "event.source.parent.Receving_Bay%i.PLCTruckRoute" % number
if event.source.text != "":
	system.tag.write( "tagPath",1)
if event.source.text == "0":
	system.tag.write( "tagPath",0)
if event.source.text == "":
	system.tag.write( "tagPath",0)`

basically I need to define which bay I am writing a Boolean value to either bay1 or bay2. I can get by with the 2 screens. but I just seems odd that I can use my UDT tags in the script editor.

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [November 10, 2016, 9:03pm UTC](https://forum.inductiveautomation.com/t/using-udt-tags-in-script-editor/12340/4 "2016-11-10T21:03:40Z")

</div>

You’re almost there. In order to use the tagPath variable, use it without the quotes in the system.tag.write call. You want to pass the value in your variable, not the literal string.

```auto
system.tag.write(tagPath,0)
```
