Is it possible to use multiple tag paths in a single Gateway tag change script

Hi everyone, I am trying to use multiple tag paths a single Gateway tag change script. I have followed the document Gateway Tag Change Script. From my understanding, we can multiple tag paths in a script, because we will have the demand to config some tag paths of a site/folder for some events. However, I do not know how to call these tag path’s values. The document seems to only show events for a single tag path.

Thank you so much for your time!

1 Like

Thanks for your reply. I think it would be more reasonable if event.getTagPath() returned an array of tagPath for example. Because we have already chosen these tags in Tag Path(s) config like in the first figure above.

There may be a better way, someone else may chime in if there is.

The tag paths list in the configuration is assigning which tag(s) will trigger the script.

event.getTagPath() returns the tag path of the tag which triggered the event.

If you want to examine the values of other tags inside of the script the only way is system.tag.readBlocking


Yep, that’s the important point. Your script will fire any time any of the tags in the change triggers change; we have no way of knowing whether they will change at the same time or not. So if they’ll all change at once, you should only have one as the trigger, and read the other values. If they can change independently, then you can have all of them as the trigger… but you’ll still want to read the other tags to get their values.

In theory you could write a sufficiently complicated script that it ‘holds on to’ the last values of the other tags and re-uses them whenever it’s triggered.
In practice I’d almost always recommend against even trying to write that. Complicated, error-prone, hard to validate. Just read the tags, it’s not as slow as you think, especially when everything’s happening on the gateway.

1 Like

Meh. Combined with the SmartMap from my utility functions, it can make some code astonishingly easy to read.