Tag Event Change Script Issue - not initialChange

Hi,
I have a VERY basic tag event change script that I am trying to run and cannot understand why it does not work. All I am trying to do is write 0 to a memory tag when a certain tag value changes in the system. I also do not want it to run on an initial change.

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	"""
	Fired whenever the current value changes in value or quality.

	Arguments:
		tag: The source tag object. A read-only wrapper for obtaining tag
		     properties.
		tagPath: The full path to the tag (String)
		previousValue: The previous value. This is a "qualified value", so it
		               has value, quality, and timestamp properties.
		currentValue: The current value. This is a "qualified value", so it has
		              value, quality, and timestamp properties.
		initialChange: A boolean flag indicating whether this event is due to
		               the first execution or initial subscription.
		missedEvents: A flag indicating that some events have been skipped due
		              to event overflow.
	"""

	if not initialChange:
		system.tag.write("[.]../Daily Actuals/Starting Count.value",0)

That being said, here is the really easy piece of script that I wrote. It works when I remove the initial change if statement, but otherwise throws an error and creates a bad tag value.

Has anyone else experienced this before?

Seems like the script should work. What does the error say?

If it’s Igntion 8, shouldn’t that be writeBlocking instead? Also might be a bit dumbon my end, but maybe just try an absolute path too?

Bad_NotFound

Tag scripts run on the gateway, so you will need to specify the tag provider with an absolute path (as @Andrew.Zebic has already alluded).

system.tag.write() will still work, but it's deprecated in favor of writeBlocking().

I'll confess, if I'm writing a quick bit of code to test, I'll still use write(). Trying to overcome 10 years of habit. :slight_smile: