Tag Event Value Changed Project Script

I have a project script (tagHistory.logTagChange()) that I’m attempting to call from within a tag value changed event script. When I do so, I get the error:

Error executing tag event script: Traceback (most recent call last): File "<tagevent:valueChanged>", line 2, in valueChanged NameError: global name 'tagHistory' is not defined

However, when I use the script console with tagHistory.logTagChange() and don’t fill in the args I get the expected error (function takes exactly 6 args). How do I scope the function so that the tag event script can find it?

Tag events can only call functions in the global scripting project. If you can’t put this function in that project, you will need to use a project event (gateway tag change event) instead of a tag event.

I guess that makes sense since tags are gateway objects and these scripts would be in the project scope.

If I only have one project on the gateway (the project that I’m calling the script from) can I still use it as the Gateway Scripting Project, or does it nee to be a stand alone project? (even if it may be advisable to have a standalone scripting project).

Yes.

Config → Gateway Settings → Gateway Scripting Project

1 Like