Tag change execute script

Hello everyone.

I would like to execute a script when a Tag change value. Is this possible? If yes could someone share, if not possible, what could be the alternative?

I'm trying to execute a script in the Project Library.
The main idea is when the tag change I would like to print a label (send the command to print). I already did the function to print, but only works if the user presses the button, I need the system to print when I have the tag changed or execute the same function as pressing the button.

Start here:
https://docs.inductiveautomation.com/display/DOC81/Tag+Event+Scripts

2 Likes

Sorry, I think I was not clear with my question, I will change it.
Thanks for the answer.
I already tried that, I'm trying to execute a script in the Project Library.
The main idea is when the tag change I would like to print a label (send the command to print). I already did the function to print, but only works if the user presses the button, I need the system to print when I have the tag changed or execute the same function as pressing the button.

Also these, which have somewhat different functionality and limitations:

Gateway Tag Change Scripts

These are defined in the project, so can call scripts in the same project.

Also consider using tag binding to Perspective session/page/view custom properties, then using a Perspective Property Change Script. These can also call scripts in the same project, but also have access to the User Interface components at their scope.

{ Do remember that all Perspective scripts run in the gateway, so will see printers and such from the gateway's viewpoint. If you have this working on a Perspective pushbutton, you should be fine. }

1 Like

Thanks, I will try your suggestion.

OK, you're trying to change a Perspective application to a gateway application (and Perspective won't be relevant anymore).

What happens when you put your button code into the tag event script?

Post your code (using the </> code formatting button).

Thanks, @Transistor and @pturmel.

@pturmel , I did your suggestion. I forgot to use Gateway Tag Change Scripts.

This is what I did.

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if previousValue <> currentValue:
		T320B.RecordWIP(self)

Thanks, again everyone.

<cough> Post your code (using the </> code formatting button).</cough>

I changed.
Thanks