Issues running Gateway Event Scripts (v7.9.6)

I’m trying to run a Gateway Tag Change Script. All I’m trying to do write to the “Truck Loading/WI_TL1” tag, once the “Modbus/W_TL1/Net” tag has been changed. I can’t seem to get this to work at all.
The purpose of the second line of code is to display a text box, but I only placed that line there to see if the code is actually running. The text box is not showing up, so either my syntax is very wrong (I’m not getting any sort of error messages though), or the script isn’t running at all.
I am running Ignition 7.9.6 on a trial mode, I’m not sure if running Gateway Event Scripts is a feature available with a license. Getting this to work on this project is pretty crucial, so I would really appreciate any help on this. Thanks a lot in advance!


tagValue =“Modbus/W_TL1/Net”)
system.gui.messageBox(“This value equals %d” % tagValue.value)
system.tag.write(“Truck Loading/WI_TL1”, tagValue.value)

Gateway event scripts can’t run a system.gui function, so your script likely isn’t doing anything because there’ll be a syntax error thrown when system.gui doesn’t exist in the gateway scope.
If you go to the gateway logs (gateway webpage -> Status -> Diagnostics -> Logs) there’s probably an error coming through saying something like system has no attribute gui.

If you just need to write the new value of the monitored tag to another tag, then you would just need something like this:
system.tag.write("[default]Truck Loading/WI_TL1", newValue.value)

newValue is a value automatically supplied to tag change scripts; see the manual for reference:

The [default] is specifying the tag provider to act on. It’s not strictly necessary in the case of tag change scripts, but is a good practice anytime you’re writing to tags from the gateway, because many gateway-level scopes cannot determine the relevant tag provider to issue writes to.

1 Like

Hey there, I really appreciate the speedy response!

It’s still not working, what exactly do I need to put within [default]? Maybe that’s the issue? I tried my gateway name, but it’s not working. Once I removed the line of code calling system.gui, I stopped getting error messages within the gateway logs, so now I’m really not sure what the issue would be. I’m trying to run the script while in preview mode and within the launched client as well, because to my understanding, gateway scripts do not run otherwise.

Thanks a lot, look forward to hearing back from you.

Unless you’ve renamed your tag provider (gateway webpage -> Configure -> Tag Providers -> Realtime), then it should be literally just [default], followed by the path to the tag, all within the literal string. You can also try removing it (it should work without it, though it’s possible things are different between 7.9 and 8 here)

Yep, that was the issue! Finally got it working. We’re running a backup that was given to us by the customer, and they had changed the realtime tag provider name. We changed [default] to that name found from the webpage path you gave, and it worked immediately, thanks a lot!