# One TAG to change another TAG (don't work)

**URL:** <https://forum.inductiveautomation.com/t/one-tag-to-change-another-tag-dont-work/88030>\
**Category:** Ignition\
**Tags:** python, ignition81, perspective, scripting\
**Created:** [March 28, 2024, 12:34pm UTC](https://forum.inductiveautomation.com/t/one-tag-to-change-another-tag-dont-work/88030 "2024-03-28T12:34:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filip\_Olsen1](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Filip\_Olsen1](https://forum.inductiveautomation.com/u/Filip_Olsen1)\
**Post date:** [March 28, 2024, 12:34pm UTC](https://forum.inductiveautomation.com/t/one-tag-to-change-another-tag-dont-work/88030/1 "2024-03-28T12:34:30Z")

</div>

Hi

I want my "Tag1" to change "Tag2" , should be simple, but it does not work.  
I`m new to code, so I cant see what is wrong.

```auto
def Tag1_changed(tag, previousValue, currentValue, quality, timestamp):
    if currentValue.value == 1:
        system.tag.writeBlocking(["Tag2"], [1])
        
system.tag.addTagChangeListener("Tag1", Tag1_changed)

```

The goal: Tag1 is MQTT tag that I control from MQTT.  
Then I want Tag2 , that is Memory tag in the PLS to trigger from the State of the MQTT tag.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 28, 2024, 12:42pm UTC](https://forum.inductiveautomation.com/t/one-tag-to-change-another-tag-dont-work/88030/2 "2024-03-28T12:42:48Z")

</div>

> [@Filip\_Olsen1](#):
>
> `system.tag.addTagChangeListener("Tag1", Tag1_changed)`

You can't just make things up. This function doesn't exist.

You're almost there though - add the logic to write to the other tag to a tag change event script.

> **[Tag Event Scripts | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/platform/tags/tag-event-scripts)**
>
> Scripts can be attached to Tags. When you edit a Tag, you can navigate to the Tag Events section and click on the Edit icon to see a list of all of the available events. Those events are

---

<div class="post-metadata">

**Author:** ![Filip\_Olsen1](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Filip\_Olsen1](https://forum.inductiveautomation.com/u/Filip_Olsen1)\
**Post date:** [March 28, 2024, 1:16pm UTC](https://forum.inductiveautomation.com/t/one-tag-to-change-another-tag-dont-work/88030/3 "2024-03-28T13:16:11Z")

</div>

> [@Kevin.Herron](#):
>
> You're almost there though - add the logic to write to the other tag to a tag change event script.

> [@Filip\_Olsen1](#):
>
> `system.tag.writeBlocking(["Tag2"], [1])`

This is supposed to write to the tag.

---

<div class="post-metadata">

**Author:** ![Filip\_Olsen1](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Filip\_Olsen1](https://forum.inductiveautomation.com/u/Filip_Olsen1)\
**Post date:** [March 28, 2024, 11:39pm UTC](https://forum.inductiveautomation.com/t/one-tag-to-change-another-tag-dont-work/88030/4 "2024-03-28T23:39:51Z")

</div>

> Tag1\_value = system.tag.readBlocking("Tag1")[0].value  
> system.tag.writeAsync("Tag2", Tag1\_value)

This worked.

---

<div class="post-metadata">

**Author:** ![Filip\_Olsen1](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Filip\_Olsen1](https://forum.inductiveautomation.com/u/Filip_Olsen1)\
**Post date:** [March 29, 2024, 12:32am UTC](https://forum.inductiveautomation.com/t/one-tag-to-change-another-tag-dont-work/88030/5 "2024-03-29T00:32:10Z")

</div>

Not sure if I should stop testing.  
I manage to copy the Tag function to work.

But it only works when I do it from my memory Tag.  
When I replace the path and name from "Default Tag1" to my "MQTT TagName" it does not copy the tag.

Is it not possible to copy all tags? do they need to be in same tag group maybe.
