# Scrip propertychange when the tag changes from inactive to active

**URL:** <https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153>\
**Category:** Ignition\
**Tags:** ignition80, vision, scripting\
**Created:** [November 16, 2021, 9:25pm UTC](https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153 "2021-11-16T21:25:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [November 16, 2021, 9:25pm UTC](https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153/1 "2021-11-16T21:25:47Z")

</div>

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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/f/9f1da23f98f69a4ff10c38349265540164718222.png)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 16, 2021, 9:38pm UTC](https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153/2 "2021-11-16T21:38:34Z")

</div>

> [@antonio.sanchez](#):
>
> but only when a tag changes from inactive to active.

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

---

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [November 16, 2021, 9:40pm UTC](https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153/3 "2021-11-16T21:40:25Z")

</div>

> [@JordanCClark](#):
>
> 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

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 16, 2021, 9:59pm UTC](https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153/4 "2021-11-16T21:59:09Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [November 16, 2021, 10:25pm UTC](https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153/5 "2021-11-16T22:25:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 16, 2021, 10:30pm UTC](https://forum.inductiveautomation.com/t/scrip-propertychange-when-the-tag-changes-from-inactive-to-active/53153/6 "2021-11-16T22:30:38Z")

</div>

[https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts](https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts)

Look for the Tag Change section.
