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.
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.
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.