Scrip propertychange when the tag changes from inactive to active

hello everyone
I have a tag that I want to fill with the information from a database, but only when a tag changes from inactive to active.

I’m thinking of creating it with the propertychange event.

but I don’t know how the structure should go to create the tag change comparison.

this is my tag

image

Forgive my confusion. Do you mean when the value goes from false to true, or when the tag goes from disabled to enabled?

the tag goes from disabled to enabled

Using a gateway tag change script you can use the newValue object. There is also event.getCurrentValue(), which gives rather the same thing rather the same thing, and event.getPreviousValue to get the values before it changed:

value, quality, t_stamp = newValue.value, newValue.quality, newValue.timestamp 

if not initialChange:
	do_some_stuff

else:	
	if quality == 'Good':
		do_some_useful_stuff
		
	elif quality == 'Bad_Disabled':
		do_other_stuff
		
	else:
		do_something_completely_different

I just don’t understand where the TAG change is going to be compared.

https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts

Look for the Tag Change section.