go back to basics-
you should be able to print into the console of a runtime client to troubleshoot.
ctrl+shift+f7 in the client, trigger the bit from designer and the print statements should output to the console tab. if not there's something else happening.
for the record, client event script firing off a tag change means all open vision clients will perform their own insert.
The machine I'm working on has 4 vision clients (HMIs), the script will be monitoring a Bool tag that will prompt my script to collect all the tag data (value) from a structure (values containing dimensions and timestamps). These values, once stored into an array, will be used with the system.db.runPrepUpdate function to run a query that will insert all the values accordingly.
According to what you just mentioned, does this mean that this script will run 4 different times?
Also, looking at the logs I noticed that I am getting a new error, it says:
"line 14, in browse_nestedTags_udts NameError: global name 'system' is not defined "
I tried importing the system library and it still gives me the same error.
Keep in mind that a Gateway Tag Change event runs in the Gateway scope, not client. Because of the scope difference you are required to provide the database connection name to system.db.runPrepUpdate.
There is also a page on the gateway where you can see a list of configured Gateway scripts and if they have executed, their execution times, and if they have an error.
Thank you Ryan, this has been great information. I was able to look into the Gateway scripts and found out that it's having an error running. Same error I posted above where it says "...'system' is not defined". Not sure why this is.
I'm guessing the snippet in OP was not the full script that's executing?
What version of Ignition are you on? I've sometimes seen the error and either 1) adding import system to the front of the script or 2) a gateway restart usually resolves the issue
Also consider defining your script in your Project Library, and then calling it from the Gateway Tag Change script. This should also resolve the issue of having to import system.
I read a previous forum that had the same issue, and I wrote "import system" at the top, before any code execution. Also, the code I'm trying to run is really big, it's mainly data formatting within defined functions and appending arrays. Its already tested and functional within the scripting console. The function that I'm interested in working is writing to the SQL. The error I'm receiving is specifically within one of my code blocks where I have a tag = system.tag.browse("parameter being passed in"). Thats where it's saying system not defined.
Put all of this in your project library, break it out into re-usable functions where you can. You can start with the entire chunk as one whole function while you work on getting it to do what you want.
It also makes your event script definitions nice and clean, a single line calling the function from the project library.
Also consider defining your script in your Project Library, and then calling it from the Gateway Tag Change script. This should also resolve the issue of having to import system.
This seemed to work! Thanks again Ryan. Breaking the code down into Functions and calling them from the Project Library did the trick. I was also importing in fnmatch and datetime, which were also conflicting with the Event script.
Note for posterity: This longstanding issue is fixed in 8.3.0, and this won't be necessary to get sane script scoping in client event scripts anymore. It's still generally a good idea to use the project library as much as possible, but not as critical.