Tag Object in Event Scripts Documentation

The documentation describes the modern approach to accessing parameters via the tag object:
paramValue =tag['parameters']['myParam']

https://docs.inductiveautomation.com/display/DOC81/Tag+Event+Scripts

A thread here alludes to some other properties:

I could not find any other documentation as to what else is contained in that object. I do a lot of string manipulation of the tagPath in event script to read properties, and I think some of those properties might be in the tag object.

Is there some more detail somewhere or even some kind of recursive introspection one can do on that tag object?

Most of the known properties are going to be from this list of constants:
https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.24/com/inductiveautomation/ignition/common/tags/config/properties/WellKnownTagProps.html

You can always dir() the object to do introspection at runtime. It looks like tag.getPropertyModel().getProperties() will also have a pretty complete list from the runtime object.

1 Like

Thanks. I'll have a look to see if there is something I can use rather than tag reads

That does not appear to work (v8.1.45).
I'm curious as to how I could interrogate the tag object itself (as is available in a tag value changed script) to see what properties are available.
dir(tags) returns the attributes listed below and its not clear how any of these would let me know I can do things like tag.name, tag.path, tag.customProperty etc.
['__class__', '__delattr__', '__doc__', '__ensure_finalizer__', '__findattr_ex__', '__finditem__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasshook__', 'equals', 'get', 'hashCode']

Use reflection/introspection (prerhaps from my inspect.py script or system.reflection.object() from my Integration Toolkit) to obtain the precise java class and/or superclasses of the object handed to your script, and log its canonical name. Look that class up in Ignition's JavaDocs to learn all of the possibilities.

Items not documented in the primary Ignition user manual are basically implementation details exposed to the SDK, and are not guaranteed to be supported in the future. (That's the whole point to leaving them out of the manual.)

If you have my toolkit installed, this one-liner will log a great deal of useful information:

	system.util.getLogger("Reflection").info(system.reflection.object(tag))

Thanks, seems like it's time I take a look into that toolkit.

1 Like