# UDT - Writing from dataset in UDT to other tags in UDT

**URL:** <https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602>\
**Category:** Ignition\
**Created:** [January 23, 2024, 12:58am UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602 "2024-01-23T00:58:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Markee](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@Mike\_Markee](https://forum.inductiveautomation.com/u/Mike_Markee)\
**Post date:** [January 23, 2024, 12:58am UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602/1 "2024-01-23T00:58:45Z")

</div>

I am trying to use a dataset that is populated by a query to populate other tags. This is all in a UDT, but I don't seem to be able to get the tags to write within the UDT.  
The image below is the dataset I am trying to pull tags from.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/8/48a2749c0569c0e73d9a4d4dbc071f8acf2de01b.png)

Below is the sample code I have been trying:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/18e34e62d2a1d4ae6219dfb823c1928ce4585285.png)

Like always, I truly appreciate the help you all offer!

Code I have tried:  
if currentValue.value \>= 1:  
#AccessLevel = system.tag.readBlocking("[.]UserLookUp[0,1]")[0]  
#AccessLevel = AccessLevel.value  
#system.tag.writeBlocking("[.]AccessLevel", AccessLevel)[0]  
ds = system.tag.readBlocking(['[.]UserLookup'])[0].value  
system.tag.writeBlocking(['[.]AccessLevel'],[ds.getValueAt(0,1)])   
else:  
print ("Code has ended")

Thank you,  
Mike

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 23, 2024, 3:12am UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602/2 "2024-01-23T03:12:21Z")

</div>

![writeBlocking](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/d/fd86b518a7abcd5412b6c1fcc13dbe0bf943f0cd.png)

What's that doing there?

Also, [system.tag.writeBlocking - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.tag.writeBlocking) is expecting a **list** of tagpaths and a **list** of values to write to those paths so that line should look like,  
`system.tag.writeBlocking(["[.]AccessLevel"], [AccessLevel])`  
It "tolerates" the misuse but that could break in a future upgrade.

* * *

Tip: while the picture of code can be useful for context, always post the (formatted) code so we don't have to type it all out to test it or use it in our answers.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 23, 2024, 3:58am UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602/3 "2024-01-23T03:58:49Z")

</div>

In addition to what @Transistor pointed out, I also am pretty sure that you can't use that notation to read a value from a dataset. You would need to read the value and process the dataset just as normal.

```python
if currentValue.value:
    ds = system.tag.readBlocking(['[.]UserLookup'])[0].value
    system.tag.writeBlocking(['[.]AccessLevel'],[ds.getValueAt(0,1)])

```

However, I believe you would be better off making the tags expression tags and using the `lookup()` expression. [lookup - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/lookup)

As a note, I'm not sure that `writeBlocking` does tolerate a string tag path and value in place of the a list. I know `readBlocking` does as that is now formally documented. I haven't actually tested it to see.

---

<div class="post-metadata">

**Author:** ![Mike\_Markee](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@Mike\_Markee](https://forum.inductiveautomation.com/u/Mike_Markee)\
**Post date:** [January 23, 2024, 1:15pm UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602/4 "2024-01-23T13:15:23Z")

</div>

I have attempted this code, and it doesn't appear to work. Is there a way to pull in the tag path for each of these tags? I know if I use the full tag path, the code will work but when utilizing a UDT I run into issues such as this.

Appreciate the help.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 23, 2024, 1:37pm UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602/5 "2024-01-23T13:37:35Z")

</div>

> [@Mike\_Markee](#):
>
> I have attempted this code, and it doesn't appear to work

The expression or the script? What indicates that it doesn't work? Don't get the expected result or an error?

> [@Mike\_Markee](#):
>
> Is there a way to pull in the tag path for each of these tags?

Not that should be done in a tag value change script.

Can you provide the code that you tried, as well as the structure of the UDT. Perhaps your relative path is incorrect.

---

<div class="post-metadata">

**Author:** ![Mike\_Markee](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@Mike\_Markee](https://forum.inductiveautomation.com/u/Mike_Markee)\
**Post date:** [January 23, 2024, 1:56pm UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602/6 "2024-01-23T13:56:49Z")

</div>

I apologize, the code did work. The PLC was overwriting it faster than ignition would update. Updates to PLC I had missed.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 23, 2024, 2:01pm UTC](https://forum.inductiveautomation.com/t/udt-writing-from-dataset-in-udt-to-other-tags-in-udt/84602/7 "2024-01-23T14:01:06Z")

</div>

> [@Mike\_Markee](#):
>
> The PLC was overwriting it faster than ignition would update.

I would recommend that you only write to a tag from one direction. Will stop races like that from being able to happen.
