Using UDT tags in script editor

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:

I think you need the absolute path to the tags.

[]Tag/SAP/Receiving_Bay1/PLCTruckRoute

See the Tag Paths section of the manual for more info:
docs.inductiveautomation.com/di … +Organized

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.

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.

system.tag.write(tagPath,0)