Script synatax on value change

I want to write a script on value changed and assign the value of a different tag to the current tag

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	"[.]Target_new" = "[.]Target"

Literal strings are not equivalent to tag values or writeable. You need to use the system.tag functions to read and write your two tags. If the script you're authoring is on the Target tag, then you can use something like this:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	system.tag.writeBlocking("[.]Target_new", currentValue.value)

https://docs.inductiveautomation.com/display/DOC81/system.tag.writeBlocking

1 Like

That seems backwards. If you want one tag to follow changes on another, you need to put the script on the source tag. Or make the destination an expression tag pointing at the source.

2 Likes

Thank you, exactly what I needed.