# Storing Value from payload using mqtt paho, system.tag.Async not working correctly with relative path in UDT

**URL:** <https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [October 7, 2021, 6:42am UTC](https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686 "2021-10-07T06:42:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakub.moric](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jakub.moric](https://forum.inductiveautomation.com/u/jakub.moric)\
**Post date:** [October 7, 2021, 6:42am UTC](https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686/1 "2021-10-07T06:42:22Z")

</div>

Dear All  
I would like to ask you for a help, iam struggling with the using system.tag.writeAsync in the change script in UDT

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/c/7c7403fbe424c69a75dc9ea590d57fd53cb58faa.png)

The first row is not working, when iam trying to write in to tag defined via relative path,but second one is working with absolute path

system.tag.readblocking is working with the relative path no problem.

I tried to read to variable using system.tag.readblocking and then using it for writeAsync but was unsuccesfull as well.

Thank you for your help

Best regards Jakub

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 7, 2021, 11:23am UTC](https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686/2 "2021-10-07T11:23:51Z")

</div>

Relative tag addressing in a tag event script depends on the execution context of the event to know where it is in the tag tree. You are attaching the `on_message` function to be executed asynchronously by another subsystem, losing the necessary context. You will need to construct the necessary absolute tag path prior to defining `on_message`, so it will be available in its closure. Or pass it to `on_message` as a default argument.

---

<div class="post-metadata">

**Author:** ![jakub.moric](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jakub.moric](https://forum.inductiveautomation.com/u/jakub.moric)\
**Post date:** [October 8, 2021, 5:05am UTC](https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686/3 "2021-10-08T05:05:33Z")

</div>

thank for your help, solve it using global variable

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/0/1089ff2903a71b2ba077680139d2cc37b4a21007.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 8, 2021, 10:55am UTC](https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686/4 "2021-10-08T10:55:11Z")

</div>

No, that’s not a solution. You are using a four-second sleep in your tag event. You can get away with it once or twice, but you will eventually hang your tag groups.

Pass the absolute path to `on_message`.

---

<div class="post-metadata">

**Author:** ![jakub.moric](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jakub.moric](https://forum.inductiveautomation.com/u/jakub.moric)\
**Post date:** [October 12, 2021, 10:12am UTC](https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686/5 "2021-10-12T10:12:01Z")

</div>

Understand,  
i used different approach without sleep reading only one payload on broker

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/32c865ef5295416b030d2ed165845a656fecd160.png)

but i would like to have one more question, if i used approach 1st or 2nd i always get error message

```
Failed to submit a listener notification task. Event loop shut down?

```

i was thinking is because i used loop in the 1st approach but in the 2nd one iam not doing any loop but still this error ☹

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 12, 2021, 12:23pm UTC](https://forum.inductiveautomation.com/t/storing-value-from-payload-using-mqtt-paho-system-tag-async-not-working-correctly-with-relative-path-in-udt/51686/6 "2021-10-12T12:23:27Z")

</div>

I would expect you to have to supply a function that will be called to receive actual values as they come in (aka a _listener_). You are using a _ **subscribe** _ operation.
